Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_type.cpp « indexer_tests « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eaa44d16397dbb96ea43f35501dd81701548ceac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "testing/testing.hpp"

#include "indexer/classificator.hpp"

namespace
{
  void check_values_array(uint8_t values[], uint8_t count)
  {
    uint32_t type = ftype::GetEmptyValue();
    uint8_t value;
    bool res = ftype::GetValue(type, 0, value);
    TEST_EQUAL(res, false, ());
    res = ftype::GetValue(type, 4, value);
    TEST_EQUAL(res, false, ());

    for (uint8_t i = 0; i < count; ++i)
      ftype::PushValue(type, values[i]);

    for (uint8_t i = 0; i < count; ++i)
    {
      res = ftype::GetValue(type, i, value);
      TEST_EQUAL(res, true, ());
      TEST_EQUAL(value, values[i], (value, values[i]));
    }

    for (char i = count-1; i >= 0; --i)
    {
      ftype::PopValue(type);

      res = ftype::GetValue(type, i, value);
      TEST_EQUAL(res, false, ());
    }

    TEST_EQUAL(type, ftype::GetEmptyValue(), (type));
  }
}

UNIT_TEST(SetGetTypes)
{
  uint8_t v1[] = { 6, 30, 0, 1 };
  check_values_array(v1, 4);
  check_values_array(v1, 3);

  uint8_t v2[] = { 0, 0, 0, 0 };
  check_values_array(v2, 4);
  check_values_array(v2, 3);

  uint8_t v3[] = { 1, 1, 1, 1 };
  check_values_array(v3, 4);
  check_values_array(v3, 3);

  uint8_t v4[] = { 63, 63, 63, 63 };
  check_values_array(v4, 4);
  check_values_array(v4, 3);
}