MCPcopy Create free account
hub / github.com/davisking/dlib / reference_counter_test

Function reference_counter_test

dlib/test/reference_counter.cpp:25–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 typename ref_counter
24 >
25 void reference_counter_test (
26 )
27 /*!
28 requires
29 - ref_counter is an implementation of reference_counter/reference_counter_kernel_abstract.h
30 and is instantiated to contain an int
31 ensures
32 - runs tests on reference_counter for compliance with the specs
33 !*/
34 {
35
36 ref_counter a, b, c;
37
38 for (long i = 0; i < 10; ++i)
39 {
40 print_spinner();
41 for (long j = 0; j < 10000; ++j)
42 {
43 a.modify() = j;
44 b.modify() = j+1;
45 c.modify() = j+2;
46 DLIB_ASSERT(a.access() == j,"");
47 DLIB_ASSERT(b.access() == j+1,"");
48 DLIB_ASSERT(c.access() == j+2,"");
49 DLIB_ASSERT(a.modify() == j,"");
50 DLIB_ASSERT(b.modify() == j+1,"");
51 DLIB_ASSERT(c.modify() == j+2,"");
52 DLIB_ASSERT(a.access() == j,"");
53 DLIB_ASSERT(b.access() == j+1,"");
54 DLIB_ASSERT(c.access() == j+2,"");
55 DLIB_ASSERT(a.modify() == j,"");
56 DLIB_ASSERT(b.modify() == j+1,"");
57 DLIB_ASSERT(c.modify() == j+2,"");
58 a = c;
59 DLIB_ASSERT(a.access() == j+2,"");
60 DLIB_ASSERT(b.access() == j+1,"");
61 DLIB_ASSERT(c.access() == j+2,"");
62 DLIB_ASSERT(a.modify() == j+2,"");
63 DLIB_ASSERT(b.modify() == j+1,"");
64 DLIB_ASSERT(c.modify() == j+2,"");
65 DLIB_ASSERT(a.access() == j+2,"");
66 DLIB_ASSERT(b.access() == j+1,"");
67 DLIB_ASSERT(c.access() == j+2,"");
68 DLIB_ASSERT(a.modify() == j+2,"");
69 DLIB_ASSERT(b.modify() == j+1,"");
70 DLIB_ASSERT(c.modify() == j+2,"");
71
72 a = b = c;
73 DLIB_ASSERT(a.access() == b.access(),"");
74 DLIB_ASSERT(a.access() == c.access(),"");
75 DLIB_ASSERT(c.access() == b.access(),"");
76 a.modify() = j;
77 DLIB_ASSERT(a.access() == j,"");
78 DLIB_ASSERT(a.access() != b.access(),"");
79 DLIB_ASSERT(a.access() != c.access(),"");
80 DLIB_ASSERT(c.access() == b.access(),"");
81 DLIB_ASSERT(c.access() == j+2,"");
82 DLIB_ASSERT(b.access() == j+2,"");

Callers

nothing calls this directly

Calls 3

print_spinnerFunction · 0.85
accessMethod · 0.80
swapFunction · 0.70

Tested by

no test coverage detected