• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Amber Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/command_data.h"
16 
17 #include "gtest/gtest.h"
18 
19 namespace amber {
20 
21 using CommandDataTest = testing::Test;
22 
TEST_F(CommandDataTest,TopologyConversions)23 TEST_F(CommandDataTest, TopologyConversions) {
24   const struct {
25     const char* name;
26     Topology val;
27   } topologies[] = {
28       {"PATCH_LIST", Topology::kPatchList},
29       {"POINT_LIST", Topology::kPointList},
30       {"GL_LINE_STRIP_ADJACENCY", Topology::kLineStripWithAdjacency},
31       {"GL_LINE_STRIP", Topology::kLineStrip},
32       {"GL_LINES", Topology::kLineList},
33       {"GL_LINES_ADJACENCY", Topology::kLineListWithAdjacency},
34       {"GL_PATCHES", Topology::kPatchList},
35       {"GL_POINTS", Topology::kPointList},
36       {"GL_TRIANGLE_STRIP", Topology::kTriangleStrip},
37       {"GL_TRIANGLE_FAN", Topology::kTriangleFan},
38       {"GL_TRIANGLES", Topology::kTriangleList},
39       {"GL_TRIANGLES_ADJACENCY", Topology::kTriangleListWithAdjacency},
40       {"GL_TRIANGLE_STRIP_ADJACENCY", Topology::kTriangleStripWithAdjacency},
41       {"LINE_LIST", Topology::kLineList},
42       {"LINE_LIST_WITH_ADJACENCY", Topology::kLineListWithAdjacency},
43       {"LINE_STRIP", Topology::kLineStrip},
44       {"LINE_STRIP_WITH_ADJACENCY", Topology::kLineStripWithAdjacency},
45       {"TRIANGLE_FAN", Topology::kTriangleFan},
46       {"TRIANGLE_LIST", Topology::kTriangleList},
47       {"TRIANGLE_LIST_WITH_ADJACENCY", Topology::kTriangleListWithAdjacency},
48       {"TRIANGLE_STRIP", Topology::kTriangleStrip},
49       {"TRIANGLE_STRIP_WITH_ADJACENCY", Topology::kTriangleStripWithAdjacency},
50   };
51 
52   for (const auto& topo : topologies) {
53     EXPECT_EQ(topo.val, NameToTopology(topo.name));
54   }
55 }
56 
TEST_F(CommandDataTest,TopologyInvalid)57 TEST_F(CommandDataTest, TopologyInvalid) {
58   EXPECT_EQ(Topology::kUnknown, NameToTopology(""));
59   EXPECT_EQ(Topology::kUnknown, NameToTopology("Invalid_Topology"));
60 }
61 
62 }  // namespace amber
63