From e1f1cdaed94e1dea7092dac022bbe6b4d6b39c9e Mon Sep 17 00:00:00 2001 From: ahcorde Date: Thu, 13 Oct 2022 00:19:07 +0200 Subject: [PATCH] Added shaderType converage Signed-off-by: ahcorde --- src/ShaderType_TEST.cc | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/ShaderType_TEST.cc diff --git a/src/ShaderType_TEST.cc b/src/ShaderType_TEST.cc new file mode 100644 index 000000000..6c48af6bd --- /dev/null +++ b/src/ShaderType_TEST.cc @@ -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 + +#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(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")); +}