19 SECTION(
"string_view") {
42 auto buf = std::to_array<uint8_t>({
'a',
'b',
'c'});
43 TclObject t(std::span<uint8_t>{buf.data(), buf.size()});
128 t = std::string(
"bar");
130 t = std::string_view(
"qux");
148 std::array<uint8_t, 3> buf = {1, 2, 3};
153 CHECK(result.data() != &buf[0]);
154 CHECK(result[0] == 1);
156 CHECK(result[0] == 1);
162 CHECK(
t .getString() ==
"1");
165 CHECK(
t .getString() ==
"1");
172 CHECK(
t .getString() ==
"1");
174 CHECK(
t .getString() ==
"1");
183 SECTION(
"no error") {
199 auto buf = std::to_array<uint8_t>({
'x',
'y',
'z'});
213 CHECK(
l3.getString() ==
"9.23");
214 CHECK(
l4.getString() ==
"bla");
230 std::array ints = {7, 6, 5};
231 std::array doubles = {1.2, 5.6};
233 SECTION(
"no error") {
262TEST_CASE(
"TclObject, addDictKeyValue(s)")
294 SECTION(
"getString") {
301 CHECK_THROWS(t0.
getInt(interp));
302 CHECK_THROWS(t1.
getInt(interp));
304 CHECK_THROWS(t3.
getInt(interp));
306 SECTION(
"getBoolean") {
312 SECTION(
"getDouble") {
327 SECTION(
"no error") {
335 SECTION(
"invalid dict") {
351 SECTION(
"not empty") {
357 CHECK(std::distance(b, e) == 10);
366 SECTION(
"invalid list") {
380 CHECK_THROWS(
TclObject(
"bla").evalBool(interp));
386 CHECK(
TclObject(
"return foobar").executeCommand(interp).getString() ==
"foobar");
387 CHECK(
TclObject(
"set n 2").executeCommand(interp).getString() ==
"2");
390 CHECK(
TclObject(
"incr n").executeCommand(interp).getString() ==
"3");
393 CHECK_THROWS(
TclObject(
"qux").executeCommand(interp));
TEST_CASE("TclObject, constructors")
CHECK(t.getDictValue(interp, "one").getInt(interp)==1)
bool getBoolean(Interpreter &interp) const
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
unsigned getListLength(Interpreter &interp) const
TclObject getListIndex(Interpreter &interp, unsigned index) const
double getDouble(Interpreter &interp) const
void addListElement(const T &t)
std::span< const uint8_t > getBinary() const
void addListElements(ITER first, ITER last)
int getInt(Interpreter &interp) const
void addDictKeyValue(const Key &key, const Value &value)
void addDictKeyValues(Args &&... args)
TclObject getDictValue(Interpreter &interp, const TclObject &key) const
zstring_view getString() const
imat3 l3(ivec3(0, 2, 3), ivec3(4, 5, 6), ivec3(7, 8, 9))
imat4 l4(ivec4(1, 2, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 0), ivec4(7, 8, 9, 0))
This file implemented 3 utility functions:
TclObject makeTclList(Args &&... args)
TclObject makeTclDict(Args &&... args)
constexpr bool equal(InputRange1 &&range1, InputRange2 &&range2, Pred pred={}, Proj1 proj1={}, Proj2 proj2={})
constexpr auto transform(Range &&range, UnaryOp op)