File: ToolEnumsTest.cpp

package info (click to toggle)
xournalpp 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,036 kB
  • sloc: cpp: 64,137; xml: 939; sh: 752; ansic: 362; python: 338; php: 74; makefile: 15
file content (45 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (2)
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
/*
 * Xournal++
 *
 * This file is part of the Xournal UnitTests
 *
 * @author Xournal++ Team
 * https://github.com/xournalpp/xournalpp
 *
 * @license GNU GPLv2 or later
 */

#include <string>

#include <config-test.h>
#include <gtest/gtest.h>

#include "control/ToolEnums.h"

/**
 * Test whether the invariant
 *     fromString(toString(x)) == x
 * holds.
 */
TEST(ToolEnumsTest, testToolSizeSerialization) {
    for (unsigned int i = 0; i <= TOOL_SIZE_NONE; i++) {
        auto toolSize = static_cast<ToolSize>(i);
        std::string s = toolSizeToString(toolSize).data();
        EXPECT_FALSE(s.empty());
        EXPECT_EQ(toolSize, toolSizeFromString(s));
    }
}

/**
 * Test whether the invariant
 *     fromString(toString(x)) == x
 * holds.
 */
TEST(ToolEnumsTest, testToolTypeSerialization) {
    for (unsigned int i = 0; i < TOOL_END_ENTRY; i++) {
        auto toolType = static_cast<ToolType>(i);
        std::string s = toolTypeToString(toolType).data();
        EXPECT_FALSE(s.empty());
        EXPECT_EQ(toolType, toolTypeFromString(s));
    }
}