diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-15 18:43:58 +0100 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-03 11:01:43 -0700 |
commit | f86333961eeacb9f2dd83a4c3680d30e06f947a7 (patch) | |
tree | e26d375a7852526196428bc86e9b7b94e2baf6f9 /test | |
parent | c1cd6759b4a87ef58442e864a192317284cf20ae (diff) | |
download | qtlocation-mapboxgl-f86333961eeacb9f2dd83a4c3680d30e06f947a7.tar.gz |
[core] cache binary shaders on Android
Diffstat (limited to 'test')
-rw-r--r-- | test/programs/binary_program.test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/programs/binary_program.test.cpp b/test/programs/binary_program.test.cpp new file mode 100644 index 0000000000..ce544e7652 --- /dev/null +++ b/test/programs/binary_program.test.cpp @@ -0,0 +1,39 @@ +#include <mbgl/test/util.hpp> + +#include <mbgl/programs/binary_program.hpp> + +using namespace mbgl; + +TEST(BinaryProgram, ObtainValues) { + const BinaryProgram binaryProgram{ 42, + "binary code", + "identifier", + { { "a_pos", 1 }, { "a_data", 4 } }, + { { "u_world", 1 }, { "u_ratio", 3 } } }; + + EXPECT_EQ(42u, binaryProgram.format()); + EXPECT_EQ("binary code", binaryProgram.code()); + EXPECT_EQ("identifier", binaryProgram.identifier()); + EXPECT_EQ(1, binaryProgram.attributeLocation("a_pos")); + EXPECT_EQ(0, binaryProgram.attributeLocation("u_world")); + EXPECT_EQ(4, binaryProgram.attributeLocation("a_data")); + EXPECT_EQ(1, binaryProgram.uniformLocation("u_world")); + EXPECT_EQ(3, binaryProgram.uniformLocation("u_ratio")); + EXPECT_EQ(0, binaryProgram.uniformLocation("a_data")); + + auto serialized = binaryProgram.serialize(); + + const BinaryProgram binaryProgram2(std::move(serialized)); + + EXPECT_EQ(42u, binaryProgram2.format()); + EXPECT_EQ("binary code", binaryProgram2.code()); + EXPECT_EQ("identifier", binaryProgram2.identifier()); + EXPECT_EQ(1, binaryProgram2.attributeLocation("a_pos")); + EXPECT_EQ(0, binaryProgram2.attributeLocation("u_world")); + EXPECT_EQ(4, binaryProgram2.attributeLocation("a_data")); + EXPECT_EQ(1, binaryProgram2.uniformLocation("u_world")); + EXPECT_EQ(3, binaryProgram2.uniformLocation("u_ratio")); + EXPECT_EQ(0, binaryProgram2.uniformLocation("a_data")); + + EXPECT_THROW(BinaryProgram(""), std::runtime_error); +} |