Added KKJ coordinate class
authorAki Koskinen <maemo@akikoskinen.info>
Sat, 27 Mar 2010 16:34:51 +0000 (18:34 +0200)
committerAki Koskinen <maemo@akikoskinen.info>
Sat, 27 Mar 2010 18:31:20 +0000 (20:31 +0200)
src/.gitignore [new file with mode: 0644]
src/kkj.cpp [new file with mode: 0644]
src/kkj.h [new file with mode: 0644]
src/src.pro [new file with mode: 0644]
tests/tests.pro
tests/ut_kkj/.gitignore [new file with mode: 0644]
tests/ut_kkj/ut_kkj.cpp [new file with mode: 0644]
tests/ut_kkj/ut_kkj.pro [new file with mode: 0644]

diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..97a5344
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+libptascommon.so*
diff --git a/src/kkj.cpp b/src/kkj.cpp
new file mode 100644 (file)
index 0000000..d60da50
--- /dev/null
@@ -0,0 +1,21 @@
+#include "kkj.h"
+
+KKJ::KKJ(unsigned int northing, unsigned int easting) :
+        mNorthing(northing),
+        mEasting(easting)
+{
+}
+
+KKJ::~KKJ()
+{
+}
+
+unsigned int KKJ::northing() const
+{
+    return mNorthing;
+}
+
+unsigned int KKJ::easting() const
+{
+    return mEasting;
+}
diff --git a/src/kkj.h b/src/kkj.h
new file mode 100644 (file)
index 0000000..3afb9b2
--- /dev/null
+++ b/src/kkj.h
@@ -0,0 +1,39 @@
+#ifndef KKJ_H
+#define KKJ_H
+
+/**
+ * A class representing the Finnish KKJ coordinate.
+ */
+class KKJ
+{
+public:
+    /**
+     * Constructs a new KKJ coordinate with the given values.
+     * @param northing the northing coordinate.
+     * @param easting the easting coordinate.
+     */
+    KKJ(unsigned int northing, unsigned int easting);
+
+    /**
+     * Destructor.
+     */
+    virtual ~KKJ();
+
+    /**
+     * Returns the northing of the coordinate.
+     * @return the northing.
+     */
+    unsigned int northing() const;
+
+    /**
+     * Returns the easting of the coordinate.
+     * @return the easting.
+     */
+    unsigned int easting() const;
+
+private:
+    unsigned int mNorthing;
+    unsigned int mEasting;
+};
+
+#endif // KKJ_H
diff --git a/src/src.pro b/src/src.pro
new file mode 100644 (file)
index 0000000..ec3edc3
--- /dev/null
@@ -0,0 +1,9 @@
+TEMPLATE = lib
+TARGET = ptascommon
+
+INSTALL_HEADERS += \
+    kkj.h
+HEADERS += \
+    $$INSTALL_HEADERS
+SOURCES += \
+    kkj.cpp
index 48dd78e..2e22c4a 100644 (file)
@@ -1,5 +1,6 @@
 TEMPLATE = subdirs
-SUBDIRS = ut_coord_trans
+SUBDIRS = \
+    ut_kkj
 
 check.target = check
 check.CONFIG = recursive
diff --git a/tests/ut_kkj/.gitignore b/tests/ut_kkj/.gitignore
new file mode 100644 (file)
index 0000000..a044d76
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+ut_kkj
diff --git a/tests/ut_kkj/ut_kkj.cpp b/tests/ut_kkj/ut_kkj.cpp
new file mode 100644 (file)
index 0000000..36cac34
--- /dev/null
@@ -0,0 +1,19 @@
+#include "kkj.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+TEST(KKJ, ConstructorValuesReceivedViaGetters)
+{
+    unsigned int northing = 6682815;
+    unsigned int easting = 2556686;
+    KKJ kkj(northing , easting);
+    ASSERT_EQ(northing, kkj.northing());
+    ASSERT_EQ(easting, kkj.easting());
+}
+
+int main(int argc, char *argv[])
+{
+    ::testing::InitGoogleMock(&argc, argv);
+    return RUN_ALL_TESTS();
+}
diff --git a/tests/ut_kkj/ut_kkj.pro b/tests/ut_kkj/ut_kkj.pro
new file mode 100644 (file)
index 0000000..2f6c4c4
--- /dev/null
@@ -0,0 +1,17 @@
+include(../ut_common.pri)
+
+TARGET = ut_kkj
+QT += testlib
+QT -= gui
+CONFIG += console
+CONFIG -= app_bundle
+TEMPLATE = app
+OBJECTS_DIR = .obj
+MOC_DIR = .moc
+SOURCES += ut_kkj.cpp \
+    $$SRCDIR/kkj.cpp
+HEADERS += \
+    $$SRCDIR/kkj.h
+
+include(../gmock.pri)
+include(../check.pri)