@@ -59,6 +59,7 @@ TEST(StringRefTest, Construction) {
5959TEST (StringRefTest, Conversion) {
6060 EXPECT_EQ (" hello" , std::string (StringRef (" hello" )));
6161 EXPECT_EQ (" hello" , std::string_view (StringRef (" hello" )));
62+ static_assert (std::string_view (StringRef (" hello" )) == " hello" );
6263}
6364
6465TEST (StringRefTest, EmptyInitializerList) {
@@ -78,9 +79,22 @@ TEST(StringRefTest, Iteration) {
7879
7980TEST (StringRefTest, StringOps) {
8081 const char *p = " hello" ;
82+
8183 EXPECT_EQ (p, StringRef (p, 0 ).data ());
84+ static_assert (StringRef (" hello" ).data ()[0 ] == ' h' );
85+ static_assert (StringRef (" hello" ).data ()[1 ] == ' e' );
86+ static_assert (StringRef (" hello" ).data ()[2 ] == ' l' );
87+ static_assert (StringRef (" hello" ).data ()[3 ] == ' l' );
88+ static_assert (StringRef (" hello" ).data ()[4 ] == ' o' );
89+ static_assert (StringRef (" hello" ).data ()[5 ] == ' \0 ' );
90+
8291 EXPECT_TRUE (StringRef ().empty ());
92+ static_assert (StringRef (" " ).empty ());
93+ static_assert (!StringRef (" hello" ).empty ());
94+
8395 EXPECT_EQ ((size_t ) 5 , StringRef (" hello" ).size ());
96+ static_assert (StringRef (" hello" ).size () == 5 );
97+
8498 EXPECT_GT ( 0 , StringRef (" aab" ).compare (" aad" ));
8599 EXPECT_EQ ( 0 , StringRef (" aab" ).compare (" aab" ));
86100 EXPECT_LT ( 0 , StringRef (" aab" ).compare (" aaa" ));
0 commit comments