diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/common/TARGETS | 12 | ||||
-rw-r--r-- | test/buildtool/common/common.test.cpp | 42 |
2 files changed, 54 insertions, 0 deletions
diff --git a/test/buildtool/common/TARGETS b/test/buildtool/common/TARGETS index 8890b8b8..c52301b4 100644 --- a/test/buildtool/common/TARGETS +++ b/test/buildtool/common/TARGETS @@ -33,6 +33,17 @@ ] , "stage": ["test", "buildtool", "common"] } +, "common": + { "type": ["@", "rules", "CC/test", "test"] + , "name": ["common"] + , "srcs": ["common.test.cpp"] + , "deps": + [ ["@", "catch2", "", "catch2"] + , ["test", "catch-main"] + , ["src/buildtool/common", "common"] + ] + , "stage": ["test", "buildtool", "common"] + } , "repository_config": { "type": ["@", "rules", "CC/test", "test"] , "name": ["repository_config"] @@ -52,6 +63,7 @@ [ "action_description" , "artifact_description" , "artifact_factory" + , "common" , "repository_config" ] } diff --git a/test/buildtool/common/common.test.cpp b/test/buildtool/common/common.test.cpp new file mode 100644 index 00000000..ea5af597 --- /dev/null +++ b/test/buildtool/common/common.test.cpp @@ -0,0 +1,42 @@ +#include "catch2/catch.hpp" +#include "src/buildtool/common/artifact.hpp" + +TEST_CASE("ObjectInfo::LiberalFromString", "[artifcat]") { + auto expected = *Artifact::ObjectInfo::FromString( + "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]"); + auto expected_as_tree = *Artifact::ObjectInfo::FromString( + "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:0:t]"); + + CHECK(Artifact::ObjectInfo::LiberalFromString( + "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:file") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:notavalidletter") == + expected); + + // Without size, which is not honored in equality + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689") == expected); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:") == expected); + // Syntactically invalid size should be ignored + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:xyz") == expected); + + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689::t") == + expected_as_tree); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689::tree") == + expected_as_tree); + CHECK(Artifact::ObjectInfo::LiberalFromString( + "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:xyz:t") == + expected_as_tree); +} |