File: TestDesktopEntryReader.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 (40 lines) | stat: -rw-r--r-- 798 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
#include <gtest/gtest.h>

#include <Reader/Reader.h>
#include <AST/AST.h>

using namespace XdgUtils::DesktopEntry::Reader;
using namespace XdgUtils::DesktopEntry::AST;

TEST(TestDesktopEntryReader, readWrite) {
    std::string data = {
        "# Test Destkop file\n"
        "[Desktop Entry]\n"
        "Name=My App\n"
        "Name[es]=Mi App\n"
    };


    Reader r;
    std::stringstream in(data);
    AST a = r.read(in);

    std::stringstream res;
    a.write(res);

    ASSERT_EQ(res.str(), data);
}

TEST(TestDesktopEntryReader, readBroken) {
    std::string data = {
        "# Test Destkop file\n"
        "[Desktop Entry]\n"
        "--Name=My App\n"
        "Name[es]=Mi App\n"
    };


    Reader r;
    std::stringstream in(data);
    ASSERT_THROW(r.read(in), std::runtime_error);
}