34 return compare(buf.capacity(), 10);
40 uint8_t data[5] = { 1, 2, 3, 4, 5 };
44 for(
size_t i = 0; i < 5; i++)
45 if(!compare(buf.read(0), data[i]))
59 for(
size_t i = 0; i < buf.capacity(); i++)
60 if(!compare(buf.read(0), 0x00))
73 for(
size_t i = 0; i < buf.capacity(); i++)
74 if(!compare(buf.read(0), 0xAA))
88 if(!compare(buf.read(0), 0x12))
return false;
89 if(!compare(buf.read(1), 0x34))
return false;
97 return compare(buf.capacity(), 10);
109 for(
size_t i = 0; i < dst.capacity(); i++)
110 if(!compare(dst.read(0), 0x55))
125 for(
size_t i = 0; i < dst.capacity(); i++)
126 if(!compare(dst.read(0), 0x77))
135 uint8_t data[3] = { 0x01, 0x02, 0x03 };
137 buf.copy_from(data, 3);
140 return compare(buf.read(0), 0x01)
141 && compare(buf.read(1), 0x02)
142 && compare(buf.read(2), 0x03);
152 uint8_t out[3] = { 0 };
155 return compare(out[0], 0x99)
156 && compare(out[1], 0x99)
157 && compare(out[2], 0x99);
170 return compare(buf.read(0), 0x30)
171 && compare(buf.read(1), 0x20)
172 && compare(buf.read(2), 0x00);
178 Buffer buf(3,
false);
185 return compare(buf.read(0), 0x33)
186 && compare(buf.read(1), 0x22)
187 && compare(buf.read(2), 0x00);
198 dst.copy_from(&src, 3);
199 return dst.read(0) == 0x55 && dst.read(1) == 0x55 && dst.read(2) == 0x55 && dst.read(3) == 0x00;
210 src.copy_to(&dst, 3);
211 return compare(dst.read(0), 0x66)
212 && compare(dst.read(1), 0x66)
213 && compare(dst.read(2), 0x66)
214 && compare(dst.read(3), 0x00);
220 buf.full(0x99, 1, 3);
221 return compare(buf.read(0), 0x00)
222 && compare(buf.read(1), 0x99)
223 && compare(buf.read(2), 0x99)
224 && compare(buf.read(3), 0x99)
225 && compare(buf.read(4), 0x00);
239 return compare(c.red, 0)
240 && compare(c.green, 0)
241 && compare(c.blue, 0)
242 && compare(c.alpha, 0);
247 Colour c(10, 20, 30);
248 return compare(c.red, 10)
249 && compare(c.green, 20)
250 && compare(c.blue, 30)
251 && compare(c.alpha, 0);
256 Colour c(10, 20, 30, 40);
257 return compare(c.red, 10)
258 && compare(c.green, 20)
259 && compare(c.blue, 30)
260 && compare(c.alpha, 40);
265 Colour c(ConsoleColour::Red);
266 return compare(c.red, 255)
267 && compare(c.green, 0)
268 && compare(c.blue, 0);
274 return compare(c.red, 255)
275 && compare(c.green, 0)
276 && compare(c.blue, 255);
281 Colour c(
"\033[0;32m");
282 return compare(c.red, 0)
283 && compare(c.green, 255)
284 && compare(c.blue, 0);
290 return c.to_console_colour() == ConsoleColour::Red;
295 Colour c(ConsoleColour::Blue);
296 return c.to_console_colour() == ConsoleColour::Blue;
301 Colour c(10, 20, 30, 128);
302 return compare(c.alpha, 128);
315 return compare(m.empty(),
true);
325 if(!compare(m.size(), 1))
330 return it != m.end() && compare(it->first, 1) && compare(it->second, 100);
341 if(!compare(m.size(), 2))
345 Pair<int, int> last = m.pop_back();
346 if(!compare(last.first, 2))
return false;
347 if(!compare(last.second, 20))
return false;
350 return compare(m.size(), 1);
361 if(!compare(m.size(), 2))
365 Pair<int, int> first = m.pop_front();
366 if(!compare(first.first, 1))
return false;
367 if(!compare(first.second, 10))
return false;
370 return compare(m.size(), 1);
380 if(!compare(m.size(), 1))
385 if(!compare(m.size(), 1))
return false;
389 if(it == m.end())
return false;
390 return compare(it->second, 200);
401 if(!compare(m.size(), 2))
return false;
405 if(!compare(m.size(), 1))
return false;
406 return (m.find(1) == m.end()) && (m.find(2) != m.end());
417 if(!compare(m.size(), 2))
return false;
421 if(it == m.end())
return false;
425 if(!compare(m.size(), 1))
return false;
426 return (m.find(1) == m.end()) && (m.find(2) != m.end());
438 return compare(m.empty(),
true) && compare(m.size(), 0);
448 if(!compare(m.size(), 0))
return false;
452 return compare(m.size(), 0);
465 if(!compare(r.left, 0))
return false;
466 if(!compare(r.top, 0))
return false;
467 if(!compare(r.width, 0))
return false;
468 if(!compare(r.height, 0))
return false;
474 Rectangle<int> r(1, 2, 3, 4);
476 if(!compare(r.left, 1))
return false;
477 if(!compare(r.top, 2))
return false;
478 if(!compare(r.width, 3))
return false;
479 if(!compare(r.height, 4))
return false;
485 Rectangle<int> r(-2, -3, -4, -5);
487 if(!compare(r.left, -6))
return false;
488 if(!compare(r.top, -8))
return false;
489 if(!compare(r.width, 4))
return false;
490 if(!compare(r.height, 5))
return false;
497 Rectangle<int> a(0, 0, 10, 10);
498 Rectangle<int> b(5, 5, 2, 2);
500 return compare(a.intersects(b),
true);
505 Rectangle<int> a(0, 0, 10, 10);
506 Rectangle<int> b(10, 10, 5, 5);
507 Rectangle<int> c(11, 0, 2, 2);
509 if(!compare(a.intersects(b),
false))
return false;
510 if(!compare(a.intersects(c),
false))
return false;
516 Rectangle<int> a(0, 0, 10, 10);
517 Rectangle<int> b(5, 5, 10, 10);
518 Rectangle<int> inter = a.intersection(b);
520 if(!compare(inter.left, 5))
return false;
521 if(!compare(inter.top, 5))
return false;
522 if(!compare(inter.width, 5))
return false;
523 if(!compare(inter.height, 5))
return false;
529 Rectangle<int> outer(0, 0, 10, 10);
530 Rectangle<int> inner(2, 2, 3, 3);
532 return compare(outer.contains(inner),
true);
537 Rectangle<int> a(0, 0, 4, 4);
538 Rectangle<int> b(4, 1, 2, 2);
539 Rectangle<int> c(-1, -1, 1, 1);
541 if(!compare(a.contains(b),
false))
return false;
542 if(!compare(a.contains(c),
false))
return false;
548 Rectangle<int> r(1, 1, 4, 4);
550 if(!compare(r.contains(1, 1),
true))
return false;
551 if(!compare(r.contains(4, 1),
false))
return false;
552 if(!compare(r.contains(3, 3),
true))
return false;
553 if(!compare(r.contains(0, 0),
false))
return false;
559 Rectangle<int> a(0, 0, 4, 4);
560 Rectangle<int> b(5, 5, 2, 2);
562 auto res = a.subtract(b);
563 const Rectangle<int>& r = res[0];
565 if(!compare((
int)res.size(), 1))
return false;
566 if(!compare(r.left, a.left))
return false;
567 if(!compare(r.top, a.top))
return false;
568 if(!compare(r.width, a.width))
return false;
569 if(!compare(r.height, a.height))
return false;
575 Rectangle<int> a(0, 0, 4, 4);
576 Rectangle<int> b(0, 0, 4, 4);
578 auto res = a.subtract(b);
579 return compare((
int)res.size(), 0);
593 return compare(s.length(), (
size_t)0);
599 return compare(s.length(), (
size_t)1) && compare(s[0],
'A');
605 return compare(s.length(), (
size_t)5) && compare(s, String(
"Hello"));
614 return compare(b, a) && compare(c, a);
622 String combined = a + String(
" ") + b;
626 return compare(combined, String(
"Hello World")) && compare(a, combined);
631 String s(
"This is a test");
632 String sub = s.substring(5, 2);
634 return compare(sub, String(
"is")) && compare(s.starts_with(String(
"This")),
true);
639 String s(
"one,two,three");
640 auto parts = s.split(String(
","));
642 if(!compare((
size_t)parts.size(), (
size_t)3))
return false;
643 if(!compare(parts[0], String(
"one")))
return false;
644 if(!compare(parts[1], String(
"two")))
return false;
645 return compare(parts[2], String(
"three"));
650 String s(
" padded ");
651 String stripped = s.strip(
' ');
652 String centered = String(
"hi").center(6,
'.');
654 if(!compare(stripped, String(
" padded")))
return false;
655 return compare(centered, String(
"..hi.."));
660 String f = String::formatted(
"num:%d hex:%x str:%s", 42, (uint64_t)0x2A, (
char*)
"ok");
662 return compare(f, String(
"num:42 hex:2A str:ok"));
667 String s = String(
"\033[0;31m") + String(
"X") + String(
"\033[0m") + String(
"Y");
670 if(!compare(s.length(
true), (
size_t)8))
return false;
671 return compare(s.length(
false), (
size_t)2);
679 return compare(r, String(
"ababab")) && compare(r.length(), (
size_t)6);
687 if(!compare(a < b,
true))
return false;
688 if(!compare(b > a,
true))
return false;
689 if(!compare(a <= a,
true))
return false;
690 return compare(b >= a,
true);
696 sb <<
"val:" << 123 << (uint64_t)0x10 <<
true;
699 if(!compare(out.starts_with(String(
"val:")),
true))
return false;
700 if(!compare(out.length() > (
size_t)5,
true))
return false;
714 Time t { 2020, 2, 1, 0, 0, 0 };
715 return compare(t.is_leap_year(),
true);
720 Time t { 2019, 3, 1, 0, 0, 0 };
721 return compare(t.is_leap_year(),
false);
726 Time t { 1970, 1, 1, 0, 0, 0 };
727 return compare(time_to_epoch(t), (uint64_t)0ULL);
732 Time t { 1970, 1, 2, 0, 0, 0 };
733 return compare(time_to_epoch(t), (uint64_t)86400ULL);
738 Time t { 1971, 1, 1, 0, 0, 0 };
739 return compare(time_to_epoch(t), (uint64_t)31536000ULL);
744 Time t { 1972, 3, 1, 0, 0, 0 };
745 return compare(time_to_epoch(t), (uint64_t)68256000ULL);
750 return compare(
string(Months[0]),
string(
"January")) && compare(
string(Months[11]),
string(
"December"));
763 return compare((
int)v.size(), 0) && compare(v.empty(),
true);
770 return compare((
size_t)v.size(), 4)
784 if(!compare((
size_t)v.size(), 3))
return false;
786 int popped = v.pop_back();
787 if(!compare(popped, 3))
return false;
788 return compare((
size_t)v.size(), 2);
798 if(!compare((
size_t)v.size(), 3))
return false;
799 if(!compare(v[0], 1))
return false;
801 int front = v.pop_front();
802 if(!compare(front, 1))
return false;
803 return compare((
size_t)v.size(), 2);
813 if(!compare((
size_t)v.size(), 2))
return false;
814 if(!compare(v[0], 9))
return false;
815 if(!compare(v[1], 8))
return false;
818 return compare(v[0], 9);
823 Vector<int> original;
824 original.push_back(4);
825 original.push_back(5);
826 Vector<int> copy = original;
829 if(!compare((
size_t)original.size(), 1))
return false;
830 return compare((
size_t)copy.size(), 2)
831 && compare(copy[1], 5);
840 Vector<int> moved =
static_cast<Vector<int>&&
>(src);
842 if(!compare((
size_t)moved.size(), 2))
return false;
843 return compare((
size_t)src.size(), 0);
854 if(!compare((
size_t)b.size(), 2))
return false;
855 if(!compare(b[1], 2))
return false;
858 c =
static_cast<Vector<int>&&
>(b);
859 if(!compare((
size_t)c.size(), 2))
return false;
860 return compare((
size_t)b.size(), 0);
872 if(!compare((
size_t)v.size(), 2))
return false;
873 return compare(v[0], 4)
883 auto it = v.begin() + 1;
886 if(!compare((
size_t)v.size(), 2))
return false;
887 return compare(v[0], 7)
898 bool found22 = (v.find(22) != v.end());
899 bool found99 = (v.find(99) != v.end());
901 if(!compare(found22,
true))
return false;
902 return compare(found99,
false);
Defines a GraphicsContext class for drawing pixels, lines, rectangles and circles to the screen.