File: test_geometry.cpp

package info (click to toggle)
biometryd 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,500 kB
  • sloc: cpp: 10,221; ansic: 191; python: 42; makefile: 20
file content (57 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (3)
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
56
57
/*
 * Copyright (C) 2016 Canonical, Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 *
 */

#include <biometry/geometry.h>

#include <gtest/gtest.h>

TEST(Point, equality_operator_works)
{
    biometry::Point p1{0.42, 0.43}; biometry::Point p2(p1);
    EXPECT_EQ(p2, p1);
    biometry::Point p3{0.43, 0.42};
    EXPECT_NE(p3, p1);
}

TEST(Point, stream_insertion_works)
{
    biometry::Point p1{0.42, 0.42};
    std::stringstream ss; ss << p1;
    EXPECT_EQ("(0.42,0.42)", ss.str());
}

TEST(Rectangle, equality_operator_works)
{
    biometry::Point p1{0.42, 0.43}; biometry::Point p2(p1);
    biometry::Rectangle r1{p1, p2}; biometry::Rectangle r2(r1);
    EXPECT_EQ(r2, r1);
    biometry::Point p3{0.43, 0.42};
    biometry::Rectangle r3{p1, p3};
    EXPECT_NE(r3, r1);
}

TEST(Rectangle, stream_insertion_works)
{
    biometry::Point p1{0.42, 0.43}; biometry::Point p2(p1);
    biometry::Rectangle r1{p1, p2};
    std::stringstream ss; ss << r1;
    EXPECT_EQ("((0.42,0.43),(0.42,0.43))", ss.str());
}