Skip to content

Commit

Permalink
Added shaderType converage (#740)
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde authored Oct 13, 2022
1 parent d4d071b commit 0c55e6a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/ShaderType_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* * Copyright (C) 2022 Open Source Robotics Foundation
*
* 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 implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <gtest/gtest.h>

#include "ignition/rendering/ShaderType.hh"

using namespace ignition;
using namespace rendering;

/////////////////////////////////////////////////
TEST(ShaderType, ShaderUtil)
{
EXPECT_TRUE(ShaderUtil::IsValid(ShaderType::ST_PIXEL));
EXPECT_TRUE(ShaderUtil::IsValid(ShaderType::ST_VERTEX));
EXPECT_TRUE(ShaderUtil::IsValid(ShaderType::ST_NORM_OBJ));
EXPECT_TRUE(ShaderUtil::IsValid(ShaderType::ST_NORM_TAN));
EXPECT_FALSE(ShaderUtil::IsValid(ShaderType::ST_UNKNOWN));

EXPECT_EQ(ShaderType::ST_PIXEL,
ShaderUtil::Sanitize(ShaderType::ST_PIXEL));
EXPECT_EQ(ShaderType::ST_UNKNOWN,
ShaderUtil::Sanitize(static_cast<ShaderType>(99)));

EXPECT_EQ("pixel", ShaderUtil::Name(ShaderType::ST_PIXEL));
EXPECT_EQ("vertex", ShaderUtil::Name(ShaderType::ST_VERTEX));
EXPECT_EQ("normal_map_object_space",
ShaderUtil::Name(ShaderType::ST_NORM_OBJ));
EXPECT_EQ("normal_map_tangent_space",
ShaderUtil::Name(ShaderType::ST_NORM_TAN));
EXPECT_EQ("UNKNOWN", ShaderUtil::Name(ShaderType::ST_UNKNOWN));

EXPECT_EQ(ST_PIXEL, ShaderUtil::Enum("pixel"));
EXPECT_EQ(ST_VERTEX, ShaderUtil::Enum("vertex"));
EXPECT_EQ(ST_NORM_OBJ, ShaderUtil::Enum("normal_map_object_space"));
EXPECT_EQ(ST_NORM_TAN, ShaderUtil::Enum("normal_map_tangent_space"));
EXPECT_EQ(ST_UNKNOWN, ShaderUtil::Enum("UNKNOWN"));
EXPECT_EQ(ST_UNKNOWN, ShaderUtil::Enum("invalid"));
}

0 comments on commit 0c55e6a

Please sign in to comment.