| 26 | "TensorLayout must be a POD except for non-trivial construction"); |
| 27 | |
| 28 | TEST(TensorLayout, Construction) { |
| 29 | TensorLayout empty; |
| 30 | EXPECT_EQ(empty.ndim(), 0); |
| 31 | EXPECT_EQ(empty.str(), string()); |
| 32 | EXPECT_STREQ(empty.c_str(), ""); |
| 33 | |
| 34 | TensorLayout from_literal = "NHWC"; |
| 35 | EXPECT_EQ(from_literal.ndim(), 4); |
| 36 | EXPECT_EQ(from_literal.str(), "NHWC"); |
| 37 | EXPECT_STREQ(from_literal.c_str(), "NHWC"); |
| 38 | |
| 39 | const char *cstr = "CHW"; |
| 40 | TensorLayout from_cstr = cstr; |
| 41 | EXPECT_EQ(from_cstr.ndim(), 3); |
| 42 | EXPECT_EQ(from_cstr.str(), "CHW"); |
| 43 | EXPECT_STREQ(from_cstr.c_str(), "CHW"); |
| 44 | |
| 45 | TensorLayout from_str = std::string("asdfg"); |
| 46 | EXPECT_EQ(from_str.ndim(), 5); |
| 47 | EXPECT_EQ(from_str.str(), "asdfg"); |
| 48 | EXPECT_STREQ(from_str.c_str(), "asdfg"); |
| 49 | } |
| 50 | |
| 51 | TEST(TensorLayout, MaxLength) { |
| 52 | // copy to a local variable to prevent GTest from requiring |
nothing calls this directly
no test coverage detected