aboutsummaryrefslogtreecommitdiff
path: root/src/descriptor_set_and_binding_parser_test.cc
diff options
context:
space:
mode:
authorJaebaek Seo <duke.acacia@gmail.com>2019-02-19 23:29:08 +0900
committerdan sinclair <dj2@everburning.com>2019-02-19 09:29:08 -0500
commitb3a778d1a66f34025878576b0be5e6a5c18c8b94 (patch)
tree13338d962c0fdf4c7bbcc16614bab51f3b9a10af /src/descriptor_set_and_binding_parser_test.cc
parent146a323c493ef0ec5705b66724f2a3636a4f1748 (diff)
downloadamber-b3a778d1a66f34025878576b0be5e6a5c18c8b94.tar.gz
Vulkan: support buffer dump (#269)
This CL adds support to dump the contents of compute buffers to a file. Fixes #36
Diffstat (limited to 'src/descriptor_set_and_binding_parser_test.cc')
-rw-r--r--src/descriptor_set_and_binding_parser_test.cc110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/descriptor_set_and_binding_parser_test.cc b/src/descriptor_set_and_binding_parser_test.cc
new file mode 100644
index 0000000..139a7ef
--- /dev/null
+++ b/src/descriptor_set_and_binding_parser_test.cc
@@ -0,0 +1,110 @@
+// Copyright 2019 The Amber Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or parseried.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/descriptor_set_and_binding_parser.h"
+
+#include "gtest/gtest.h"
+
+namespace amber {
+
+using DescriptorSetAndBindingParserTest = testing::Test;
+
+TEST_F(DescriptorSetAndBindingParserTest, CommaAndBinding) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse(",1234");
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ EXPECT_EQ(0, parser.GetDescriptorSet());
+ EXPECT_EQ(1234, parser.GetBinding());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, Binding) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("1234");
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ EXPECT_EQ(0, parser.GetDescriptorSet());
+ EXPECT_EQ(1234, parser.GetBinding());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, DescSetAndBinding) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("1234,5678");
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ EXPECT_EQ(1234, parser.GetDescriptorSet());
+ EXPECT_EQ(5678, parser.GetBinding());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, EmptyBufferId) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("");
+ EXPECT_EQ("Invalid buffer id: ", r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, InvalidCharacter) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("abcd");
+ EXPECT_EQ("Invalid buffer id: abcd", r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, InvalidCharacterBetweenTwoNumbers) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("1234a5678");
+ EXPECT_EQ("Invalid buffer id: 1234a5678", r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, InvalidCharacterAfterComma) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("1234,a5678");
+ EXPECT_EQ(
+ "Binding for a buffer must be non-negative integer, but you gave: a5678",
+ r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, NegativeDescSet) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("-1234,5678");
+ EXPECT_EQ(
+ "Descriptor set and binding for a buffer must be non-negative integer, "
+ "but you gave: -1234",
+ r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, NegativeBindingAfterComma) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse(",-1234");
+ EXPECT_EQ(
+ "Binding for a buffer must be non-negative integer, but you gave: -1234",
+ r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, NegativeBinding) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("-1234");
+ EXPECT_EQ(
+ "Descriptor set and binding for a buffer must be non-negative integer, "
+ "but you gave: -1234",
+ r.Error());
+}
+
+TEST_F(DescriptorSetAndBindingParserTest, DescSetAndNegativeBinding) {
+ DescriptorSetAndBindingParser parser;
+ Result r = parser.Parse("1234,-5678");
+ EXPECT_EQ(
+ "Binding for a buffer must be non-negative integer, but you gave: -5678",
+ r.Error());
+}
+
+} // namespace amber