| 34 | #endif |
| 35 | |
| 36 | TEST(string_view, construct_as_constexpr) { |
| 37 | { |
| 38 | constexpr StringView view {}; |
| 39 | ASSERT_TRUE(view.empty()); |
| 40 | } |
| 41 | { |
| 42 | constexpr StringView view = "10086"; |
| 43 | ASSERT_EQ(5, view.size()); |
| 44 | } |
| 45 | { |
| 46 | constexpr StringView view("10086"); |
| 47 | ASSERT_EQ(5, view.size()); |
| 48 | } |
| 49 | { |
| 50 | constexpr StringView view("10086", 4); |
| 51 | ASSERT_EQ(4, view.length()); |
| 52 | } |
| 53 | { |
| 54 | constexpr StringView view("10086", 4); |
| 55 | constexpr StringView same_view(view); |
| 56 | ASSERT_EQ(4, same_view.length()); |
| 57 | } |
| 58 | #if __cplusplus >= 201402L |
| 59 | { |
| 60 | constexpr StringView view("10086", 4); |
| 61 | constexpr StringView same_view = use_assing_operator_in_constexpr(view); |
| 62 | ASSERT_EQ(4, same_view.length()); |
| 63 | } |
| 64 | #endif // __cplusplus |
| 65 | } |
| 66 | |
| 67 | TEST(string_view, get_char_as_constexpr) { |
| 68 | constexpr StringView view = "10086"; |
nothing calls this directly
no test coverage detected