Differential D14871 Diff 51223 source/blender/io/wavefront_obj/tests/obj_import_string_utils_tests.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/wavefront_obj/tests/obj_import_string_utils_tests.cc
- This file was moved from source/blender/io/common/intern/string_utils_test.cc.
| /* SPDX-License-Identifier: Apache-2.0 */ | /* SPDX-License-Identifier: Apache-2.0 */ | ||||
| #include "IO_string_utils.hh" | #include "obj_import_string_utils.hh" | ||||
| #include "testing/testing.h" | #include "testing/testing.h" | ||||
| namespace blender::io { | namespace blender::io::obj { | ||||
| #define EXPECT_STRREF_EQ(str1, str2) EXPECT_STREQ(str1, std::string(str2).c_str()) | #define EXPECT_STRREF_EQ(str1, str2) EXPECT_STREQ(str1, std::string(str2).c_str()) | ||||
| TEST(string_utils, read_next_line) | TEST(obj_import_string_utils, read_next_line) | ||||
| { | { | ||||
| std::string str = "abc\n \n\nline with \\\ncontinuation\nCRLF ending:\r\na"; | std::string str = "abc\n \n\nline with \\\ncontinuation\nCRLF ending:\r\na"; | ||||
| StringRef s = str; | StringRef s = str; | ||||
| Context not available. | |||||
| EXPECT_TRUE(s.is_empty()); | EXPECT_TRUE(s.is_empty()); | ||||
| } | } | ||||
| TEST(string_utils, drop_whitespace) | TEST(obj_import_string_utils, drop_whitespace) | ||||
| { | { | ||||
| /* Empty */ | /* Empty */ | ||||
| EXPECT_STRREF_EQ("", drop_whitespace("")); | EXPECT_STRREF_EQ("", drop_whitespace("")); | ||||
| Context not available. | |||||
| EXPECT_STRREF_EQ("d", drop_whitespace(" \\ d")); | EXPECT_STRREF_EQ("d", drop_whitespace(" \\ d")); | ||||
| } | } | ||||
| TEST(string_utils, parse_int_valid) | TEST(obj_import_string_utils, parse_int_valid) | ||||
| { | { | ||||
| std::string str = "1 -10 \t 1234 1234567890 +7 123a"; | std::string str = "1 -10 \t 1234 1234567890 +7 123a"; | ||||
| StringRef s = str; | StringRef s = str; | ||||
| Context not available. | |||||
| EXPECT_STRREF_EQ("a", s); | EXPECT_STRREF_EQ("a", s); | ||||
| } | } | ||||
| TEST(string_utils, parse_int_invalid) | TEST(obj_import_string_utils, parse_int_invalid) | ||||
| { | { | ||||
| int val; | int val; | ||||
| /* Invalid syntax */ | /* Invalid syntax */ | ||||
| Context not available. | |||||
| EXPECT_EQ(val, -4); | EXPECT_EQ(val, -4); | ||||
| } | } | ||||
| TEST(string_utils, parse_float_valid) | TEST(obj_import_string_utils, parse_float_valid) | ||||
| { | { | ||||
| std::string str = "1 -10 123.5 -17.125 0.1 1e6 50.0e-1"; | std::string str = "1 -10 123.5 -17.125 0.1 1e6 50.0e-1"; | ||||
| StringRef s = str; | StringRef s = str; | ||||
| Context not available. | |||||
| EXPECT_TRUE(s.is_empty()); | EXPECT_TRUE(s.is_empty()); | ||||
| } | } | ||||
| TEST(string_utils, parse_float_invalid) | TEST(obj_import_string_utils, parse_float_invalid) | ||||
| { | { | ||||
| float val; | float val; | ||||
| /* Invalid syntax */ | /* Invalid syntax */ | ||||
| Context not available. | |||||
| EXPECT_EQ(val, -4.0f); | EXPECT_EQ(val, -4.0f); | ||||
| } | } | ||||
| } // namespace blender::io | } // namespace blender::io::obj | ||||
| Context not available. | |||||