MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / test_console_variables

Function test_console_variables

tests/src/engine/test_console_objects.cpp:65–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void test_console_variables()
66{
67 console::ResetAll();
68
69 static char const* name = "float3cvar";
70 static char const* description = "The description of float3cvar is very descriptive.";
71 float3 value(.1f, .2f, .3f),
72 value2(.4f, .5f, .6f),
73 value3(.7f, .8f, .9f);
74
75 // auto-instantiation
76 cvarFloat3 var = cvarFloat3(name, description, value);
77 CHECK(all(var.GetValue() == value));
78 CHECK(all(var.GetValue() != value2));
79 CHECK(std::strcmp(var.GetName().c_str(), name)==0);
80 CHECK(std::strcmp(var.GetDescription().c_str(), description)==0);
81
82 console::VariableState state = var.GetState();
83 CHECK(state.IsInitalized()==true);
84 CHECK(state.setby == console::VariableState::CODE);
85 CHECK(state.type == console::VariableType::TYPE_FLOAT3);
86
87 // reference copy
88 cvarFloat3 varcopy = var;
89 CHECK(all(varcopy.GetValue() == value));
90 CHECK(std::strcmp(varcopy.GetName().c_str(), name) == 0);
91 CHECK(std::strcmp(varcopy.GetDescription().c_str(), description) == 0);
92 CHECK(state == varcopy.GetState());
93
94 // set value
95 CHECK(var.GetState().CanSetValue());
96 var.SetValue(value2);
97 CHECK(all(var.GetValue() == value2));
98 CHECK(all(varcopy.GetValue() == value2));
99
100 // find
101 CHECK(console::FindVariable("foo") == nullptr);
102 if (cvar* pvar = console::FindVariable(name))
103 {
104 CHECK(pvar->IsBool() == false);
105 CHECK(pvar->IsFloat3() == true);
106 CHECK(pvar->IsString() == false);
107 CHECK(all(pvar->GetFloat3() == value2));
108 CHECK(strcmp(pvar->GetName().c_str(), name) == 0);
109 CHECK(std::strcmp(pvar->GetDescription().c_str(), description) == 0);
110 CHECK(pvar->GetState() == state);
111
112 pvar->SetFloat3(value);
113 CHECK(all(pvar->GetFloat3() == value));
114 CHECK(pvar->GetValueAsString() == "0.100000 0.200000 0.300000");
115
116 // read-only
117 std::pair<donut::log::Severity, std::string> err;
118 donut::log::SetCallback([&](donut::log::Severity s, char const* msg) {
119 err = { s, msg };
120 });
121
122 CHECK(pvar->GetState().read_only == false);

Callers 1

mainFunction · 0.85

Calls 15

ResetAllFunction · 0.85
FindVariableFunction · 0.85
SetCallbackFunction · 0.85
GetStateMethod · 0.80
IsInitalizedMethod · 0.80
CanSetValueMethod · 0.80
IsBoolMethod · 0.80
IsFloat3Method · 0.80
IsStringMethod · 0.80
GetFloat3Method · 0.80
SetFloat3Method · 0.80
SetReadOnlyMethod · 0.80

Tested by

no test coverage detected