--------------------------------------------------------------
| 77 | |
| 78 | //-------------------------------------------------------------- |
| 79 | void ofApp::runTests() { |
| 80 | |
| 81 | // do tests |
| 82 | //------ |
| 83 | ofLog(); |
| 84 | ofLog() << "*** BEGIN READ TEST ***"; |
| 85 | |
| 86 | // load a script with some variables we want |
| 87 | lua.doScript("variableTest.lua"); |
| 88 | |
| 89 | // prints global table if no table is pushed |
| 90 | //lua.printTable(); |
| 91 | |
| 92 | // print the glm module table |
| 93 | //lua.printTable("glm"); |
| 94 | |
| 95 | // print the variables in the script manually |
| 96 | ofLog() << "variableTest variables:"; |
| 97 | ofLog() << " abool: " << lua.getBool("abool"); |
| 98 | ofLog() << " anumber: " << lua.getNumber("anumber"); |
| 99 | ofLog() << " astring: " << lua.getString("astring"); |
| 100 | |
| 101 | // load simple table arrays by type |
| 102 | stringstream line; |
| 103 | |
| 104 | vector<bool> boolTable; |
| 105 | lua.getBoolVector("boolTable", boolTable); |
| 106 | line << " boolTable: "; |
| 107 | for(size_t i = 0; i < boolTable.size(); ++i) { |
| 108 | line << boolTable[i] << " "; |
| 109 | } |
| 110 | ofLog() << line.str() << "#: " << lua.tableSize("boolTable"); |
| 111 | line.str(""); // clear |
| 112 | |
| 113 | vector<lua_Number> numberTable; |
| 114 | lua.getNumberVector("numberTable", numberTable); |
| 115 | line << " numberTable: "; |
| 116 | for(size_t i = 0; i < numberTable.size(); ++i) { |
| 117 | line << numberTable[i] << " "; |
| 118 | } |
| 119 | ofLog() << line.str() << "#: " << lua.tableSize("numberTable"); |
| 120 | line.str(""); // clear |
| 121 | |
| 122 | vector<string> stringTable; |
| 123 | lua.getStringVector("stringTable", stringTable); |
| 124 | line << " stringTable: "; |
| 125 | for(size_t i = 0; i < stringTable.size(); ++i) { |
| 126 | line << "\"" << stringTable[i] << "\" "; |
| 127 | } |
| 128 | ofLog() << line.str() << "#: " << lua.tableSize("stringTable"); |
| 129 | line.str(""); // clear |
| 130 | |
| 131 | // try to load a mixed var table, should fail and issue warnings |
| 132 | ofLog() << " ### should be warnings here vvv"; |
| 133 | vector<string> testStringVector; |
| 134 | lua.getStringVector("mixedTable", testStringVector); |
| 135 | ofLog() << " ### should be warnings here ^^^"; |
| 136 |
nothing calls this directly
no test coverage detected