- Fix rgba2hex
- Add tests
pull/3882/head
kkulling 2021-05-05 14:43:51 +02:00
parent f15dcfa981
commit 2a6b84c8ea
9 changed files with 25448 additions and 3 deletions

View File

@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib> #include <cstdlib>
#include <locale> #include <locale>
#include <sstream> #include <sstream>
#include <iomanip>
#ifdef _MSC_VER #ifdef _MSC_VER
#define AI_SIZEFMT "%Iu" #define AI_SIZEFMT "%Iu"
@ -176,7 +177,7 @@ AI_FORCE_INLINE std::string ai_rgba2hex(int r, int g, int b, int a, bool with_he
if (with_head) { if (with_head) {
ss << "#"; ss << "#";
} }
ss << std::hex << (r << 24 | g << 16 | b << 8 | a); ss << std::hex << std::setfill('0') << std::setw(8) << (r << 24 | g << 16 | b << 8 | a);
return ss.str(); return ss.str();
} }

3184
test/AssimpLog_C.txt 100644

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

80
test/dae.dae 100644
View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Assimp</author>
<authoring_tool>Assimp Exporter</authoring_tool>
</contributor>
<created>2021-05-05T14:41:31</created>
<modified>2021-05-05T14:41:31</modified>
<unit name="meter" meter="1" />
<up_axis>Y_UP</up_axis>
</asset>
<library_images>
</library_images>
<library_effects>
<effect id="material_0-fx" name="">
<profile_COMMON>
<technique sid="standard">
<phong>
<diffuse>
<color sid="diffuse">1 0 0 1</color>
</diffuse>
<transparency>
<float sid="transparency">0.0373546556</float>
</transparency>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="material_0" name="">
<instance_effect url="#material_0-fx"/>
</material>
</library_materials>
<library_geometries>
<geometry id="mesh_0" name="" >
<mesh>
<source id="mesh_0-positions" name="mesh_0-positions">
<float_array id="mesh_0-positions-array" count="9"> 1 0 0 0 1 0 0 0 1 </float_array>
<technique_common>
<accessor count="3" offset="0" source="#mesh_0-positions-array" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<vertices id="mesh_0-vertices">
<input semantic="POSITION" source="#mesh_0-positions" />
</vertices>
<polylist count="1" material="defaultMaterial">
<input offset="0" semantic="VERTEX" source="#mesh_0-vertices" />
<vcount>3 </vcount>
<p>0 1 2 </p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers>
</library_controllers>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="node" name="" type="NODE">
<matrix sid="matrix">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
<instance_geometry url="#mesh_0">
<bind_material>
<technique_common>
<instance_material symbol="defaultMaterial" target="#material_0">
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene" />
</scene>
</COLLADA>

8008
test/dna.txt 100644

File diff suppressed because it is too large Load Diff

10946
test/spiderExport.stl 100644

File diff suppressed because it is too large Load Diff

BIN
test/test.3mf 100644

Binary file not shown.

View File

@ -0,0 +1,33 @@
solid Assimp_Pointcloud
facet normal 0 0 0
vertex 0 0 0
vertex 0 0 0
vertex 0 0 0
vertex 1 1 1
vertex 1 1 1
vertex 1 1 1
vertex 2 2 2
vertex 2 2 2
vertex 2 2 2
vertex 3 3 3
vertex 3 3 3
vertex 3 3 3
vertex 4 4 4
vertex 4 4 4
vertex 4 4 4
vertex 5 5 5
vertex 5 5 5
vertex 5 5 5
vertex 6 6 6
vertex 6 6 6
vertex 6 6 6
vertex 7 7 7
vertex 7 7 7
vertex 7 7 7
vertex 8 8 8
vertex 8 8 8
vertex 8 8 8
vertex 9 9 9
vertex 9 9 9
vertex 9 9 9
endsolid Assimp_Pointcloud

View File

@ -42,9 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/StringUtils.h> #include <assimp/StringUtils.h>
class utStringUtils : public ::testing::Test { class utStringUtils : public ::testing::Test {
// empty
}; };
TEST_F( utStringUtils, to_string_Test ) { TEST_F(utStringUtils, to_string_Test ) {
std::string res = ai_to_string( 1 ); std::string res = ai_to_string( 1 );
EXPECT_EQ( res, "1" ); EXPECT_EQ( res, "1" );
@ -52,7 +53,7 @@ TEST_F( utStringUtils, to_string_Test ) {
EXPECT_EQ( res, "1" ); EXPECT_EQ( res, "1" );
} }
TEST_F( utStringUtils, ai_strtofTest ) { TEST_F(utStringUtils, ai_strtofTest ) {
float res = ai_strtof( nullptr, nullptr ); float res = ai_strtof( nullptr, nullptr );
EXPECT_FLOAT_EQ( res, 0.0f ); EXPECT_FLOAT_EQ( res, 0.0f );
@ -66,3 +67,11 @@ TEST_F( utStringUtils, ai_strtofTest ) {
res = ai_strtof( begin, end ); res = ai_strtof( begin, end );
EXPECT_FLOAT_EQ( res, 200.0f ); EXPECT_FLOAT_EQ( res, 200.0f );
} }
TEST_F(utStringUtils, ai_rgba2hexTest) {
std::string result;
result = ai_rgba2hex(255, 255, 255, 255, true);
EXPECT_EQ(result, "#ffffffff");
result = ai_rgba2hex(0, 0, 0, 0, false);
EXPECT_EQ(result, "00000000");
}