Build system improvements
[ustl.git] / bvt / bvt00.cc
blobf908fa2c2feed8983bc804fc87f4cccf0eb4552c
1 // This file is part of the ustl library, an STL implementation.
2 //
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
5 //
7 #include "stdtest.h"
9 void WriteCML (const cmemlink& l)
11 cout.format ("cmemlink{%zu}: ", l.size());
12 const void* pv = l.cdata();
13 const char* pc = reinterpret_cast<const char*>(pv);
14 size_t nc = l.size();
15 if (pc[nc - 1] == 0)
16 -- nc;
17 cout.write (l.begin(), nc);
18 cout << endl;
21 void TestCML (void)
23 const char hello[] = "Hello world!";
24 const char* phello = hello; // const storage is sometimes copied on pointing
26 cmemlink a, b;
27 a.link (phello, VectorSize(hello));
28 if (a.begin() != phello)
29 cout.format ("a.begin() failed: %p != %p\n", a.begin(), phello);
30 a.link (VectorRange (hello));
31 if (*(const char*)(a.begin() + 5) != hello[5])
32 cout.format ("begin()[5] failed: %c != %c\n", *(const char*)(a.begin() + 5), VectorElement(hello,5));
33 if (a.size() != VectorSize(hello))
34 cout << "link to VectorRange doesn't work\n";
35 if (0 != memcmp (a.begin(), hello, VectorSize(hello)))
36 cout << "memcmp failed on cmemlink\n";
37 b.static_link (hello);
38 WriteCML (a);
39 WriteCML (b);
40 if (!(a == b))
41 cout << "operator== failed on cmemlink\n";
42 b.resize (VectorSize(hello) - 5);
43 a = b;
44 WriteCML (a);
47 StdBvtMain (TestCML)