Skip to content

Commit

Permalink
Fix test case to handle unsupported locale
Browse files Browse the repository at this point in the history
Move utility python script into contrib
  • Loading branch information
ashwinbhat committed Apr 30, 2021
1 parent 57fed13 commit 8032b13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions source/MaterialXContrib/Utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts/" DESTINATION "${CMAKE_INSTALL_PREFIX}/python" MESSAGE_NEVER)
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ def export_hpp(elem, filename):
inputname=inp.getName(),
declaration=decl)
variable_defs += variable_def
#print (variable_def)
struct_definition = """struct {structname} {{\n{variabledefs}}};""" \
.format(structname = elem.getNodeString(),
variabledefs = variable_defs)
nodename_definition = ' std::string _nodename_ = "{nodename}";\n'.format(nodename= elem.getNodeString())
struct_definition = """struct {structname} {{\n{variabledefs}{nodeiddef}}};""" \
.format(structname = elem.getName(),
variabledefs = variable_defs,
nodeiddef = nodename_definition)

with open(filename, 'w', encoding='utf-8') as f:
f.write(preamble)
Expand Down
12 changes: 9 additions & 3 deletions source/MaterialXTest/MaterialXFormat/XmlIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,15 @@ TEST_CASE("Load locale content", "[xmlio_locale]")
/// Thus one thousandand twenty - five is displayed as 1, 025 in the United States and 1.025 in Germany.In Sweden, the thousands separator is a space.
/// mx:Vector3(1,1.5,2.0) should be interpreted as float[3] = [1.0f, 1.5f, 2.0f]

//Set locale to de
std::locale deLocale("de_DE");
std::locale::global(deLocale);
try {
//Set locale to de
std::locale deLocale("de_DE");
std::locale::global(deLocale);
}
catch (const std::runtime_error& e) {
WARN("Unable to change locale " << e.what());
return;
}

mx::FilePath libraryPath("libraries/stdlib");
mx::FilePath testPath("resources/Materials/TestSuite/locale");
Expand Down

0 comments on commit 8032b13

Please sign in to comment.