19 SECTION(
"string_view") {
42 uint8_t buf[] = {
'a',
'b',
'c'};
128 t = std::string(
"bar");
130 t = std::string_view(
"qux");
148 uint8_t buf[] = {1, 2, 3};
151 CHECK(result.size() ==
sizeof(buf));
152 CHECK(memcmp(buf, result.data(), result.size()) == 0);
154 CHECK(result.data() != &buf[0]);
155 CHECK(result[0] == 1);
157 CHECK(result[0] == 1);
163 CHECK(
t .getString() ==
"1");
166 CHECK(
t .getString() ==
"1");
173 CHECK(
t .getString() ==
"1");
175 CHECK(
t .getString() ==
"1");
184 SECTION(
"no error") {
200 uint8_t buf[] = {
'x',
'y',
'z'};
214 CHECK(
l3.getString() ==
"9.23");
215 CHECK(
l4.getString() ==
"bla");
231 int ints[] = {7, 6, 5};
232 double doubles[] = {1.2, 5.6};
234 SECTION(
"no error") {
263 TEST_CASE(
"TclObject, addDictKeyValue(s)")
295 SECTION(
"getString") {
302 CHECK_THROWS(t0.
getInt(interp));
303 CHECK_THROWS(t1.
getInt(interp));
305 CHECK_THROWS(t3.
getInt(interp));
307 SECTION(
"getBoolean") {
313 SECTION(
"getDouble") {
328 SECTION(
"no error") {
336 SECTION(
"invalid dict") {
352 SECTION(
"not empty") {
367 SECTION(
"invalid list") {
381 CHECK_THROWS(
TclObject(
"bla").evalBool(interp));
387 CHECK(
TclObject(
"return foobar").executeCommand(interp).getString() ==
"foobar");
388 CHECK(
TclObject(
"set n 2").executeCommand(interp).getString() ==
"2");
391 CHECK(
TclObject(
"incr n").executeCommand(interp).getString() ==
"3");
394 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)
void addListElements(ITER first, ITER last)
int getInt(Interpreter &interp) const
void addDictKeyValue(const Key &key, const Value &value)
void addDictKeyValues(Args &&... args)
span< const uint8_t > getBinary() const
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)
void advance(octet_iterator &it, distance_type n, octet_iterator end)
auto distance(octet_iterator first, octet_iterator last)
constexpr auto transform(Range &&range, UnaryOp op)
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)