File: TestComment.cpp

package info (click to toggle)
xdg-utils-cxx 1.0.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 456 kB
  • sloc: cpp: 2,461; ansic: 10; makefile: 6
file content (42 lines) | stat: -rw-r--r-- 1,119 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
#include <gtest/gtest.h>

#include <Comment.h>

using namespace XdgUtils::DesktopEntry::AST;

TEST(TestComment, create) {
    Comment comment1("# Test", " Test");

    ASSERT_EQ(" Test", comment1.getValue());
}

TEST(TestComment, setValue) {
    Comment comment1("# Test", " Test");

    comment1.setValue(" More Tests!");
    ASSERT_EQ(" More Tests!", comment1.getValue());

    std::stringstream out;
    comment1.write(out);

    ASSERT_EQ("# More Tests!", out.str());
}

TEST(TestComment, setValueToEmpty) {
    Comment comment1("", "");
    comment1.setValue(" More Tests!");
    ASSERT_EQ(" More Tests!", comment1.getValue());

    std::stringstream out;
    comment1.write(out);

    ASSERT_EQ("# More Tests!", out.str());
}

TEST(TestComment, compare) {
    ASSERT_EQ(Comment("", ""), Comment("", ""));
    ASSERT_EQ(Comment("# ", " Random Rocker"), Comment("# ", " Random Rocker"));
    ASSERT_EQ(Comment("# ", " Random Rocker"), Comment("#", " Random Rocker"));
    ASSERT_NE(Comment("# ", " Random Blocker"), Comment("#", " Random Rocker"));
    ASSERT_NE(Comment("", ""), Comment("#", " Random Rocker"));
}