OSDN Git Service

A tests/opt/style: add a directory
authornogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Fri, 3 Jul 2009 21:05:34 +0000 (21:05 +0000)
committernogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Fri, 3 Jul 2009 21:05:34 +0000 (21:05 +0000)
A    tests/opt/style/stylefilltest.cpp: add tests for StyleFill
A    tests/opt/style/CMakeLists.txt: add tests for StyleFill
A    tests/opt/terminal: add a directory
A    tests/opt/terminal/terminalpbmtest.cpp: add tests for TerminalPbm
A    tests/opt/terminal/CMakeLists.txt: add tests for TermianlPbm
M    tests/opt/CMakeLists.txt: add two sub directories
M    src/opt/terminal/terminalpbm.h: add comments
M    src/opt/terminal/terminalpbm.cpp: update years
M    src/opt/style/stylefill.cpp: fix a bug
M    src/opt/style/stylefill.h: add comments

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/cueplot/trunk@1027 3964cfc2-352b-0410-b06c-9ff7d3e98643

src/opt/style/stylefill.cpp
src/opt/style/stylefill.h
src/opt/terminal/terminalpbm.cpp
src/opt/terminal/terminalpbm.h
tests/opt/CMakeLists.txt
tests/opt/style/CMakeLists.txt [new file with mode: 0644]
tests/opt/style/stylefilltest.cpp [new file with mode: 0644]
tests/opt/terminal/CMakeLists.txt [new file with mode: 0644]
tests/opt/terminal/terminalpbmtest.cpp [new file with mode: 0644]

index 81a1c10..caa8299 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -105,21 +105,21 @@ int StyleFill::lineType() const
 
 QString StyleFill::command() const
 {
-       QString str = "set style fill ";
+       QString str = "set style fill";
        if (style_ == EMPTY) {
-               str += "empty ";
+               str += " empty";
        } else if (style_ == SOLID) {
-               str += "solid " + QString::number(density_) + ' ';
+               str += " solid " + QString::number(density_);
        } else if (style_ == PATTERN) {
-               str += "pattern " + QString::number(pattern_) + ' ';
+               str += " pattern " + QString::number(pattern_);
        }
        if (isBorder_) {
-               str += "border";
-       } else {
-               str += "noborder";
+               str += " border";
                if (lineType_ != DEFAULT_LINE_TYPE) {
                        str += ' ' + QString::number(lineType_);
                }
+       } else {
+               str += " noborder";
        }
        return str;
 }
index 7af6bf5..4763ff9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -27,25 +27,72 @@ class StyleFill : public AbstractOption
        public:
                StyleFill();
 
+               /// 塗りつぶさないように設定する
                void setEmpty();
+               /*!
+                * \brief 塗りつぶさないかどうかを設定する
+                * \return 塗りつぶさないならば true
+                */
                bool isEmpty() const;
 
+               /// 無地で塗りつぶすように設定する
                void setSolid();
+               /*!
+                * \brief 無地で塗りつぶすかどうかを設定する
+                * \return 無地で塗りつぶすならば true
+                */
                bool isSolid() const;
 
+               /*!
+                * \brief 塗りつぶしの濃さを設定する
+                * \param density 設定する塗りつぶしの濃さ
+                */
                void setDensity(double density);
+               /*!
+                * \brief 塗りつぶしの濃さを得る
+                * \return 塗りつぶしの濃さ
+                */
                double density() const;
 
+               /// パターンで塗りつぶすように設定する
                void setPattern();
+               /*!
+                * \brief パターンで塗りつぶすかどうかを設定する
+                * \return パターンで塗りつぶすならば true
+                */
                bool isPattern() const;
 
+               /*!
+                * \brief 塗りつぶしのパターンを設定する
+                * \param n 設定する塗りつぶしのパターン
+                */
                void setPattern(int n);
+               /*!
+                * \brief 塗りつぶしのパターンを得る
+                * \return 塗りつぶしのパターン
+                */
                int pattern() const;
 
+               /*!
+                * \brief 境界線を表示するかどうかを設定する
+                * \param border 境界線を表示するかどうか
+                */
                void setBorder(bool border);
+               /*!
+                * \brief 境界線を表示するかどうかを返す
+                * \return 境界線を表示するならば true
+                */
                bool isBorder() const;
 
+               /*!
+                * \brief 境界線の種類を設定する
+                * \param type 設定する境界線の種類
+                */
                void setLineType(int type);
+               /*!
+                * \brief 境界線の種類を得る
+                * \return 境界線の種類
+                */
                int lineType() const;
 
                QString command() const;
index 3d3b0b5..f48e543 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ * Copyright (C) 2007, 2008, 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
index b3dabaf..2fa8b5c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -29,10 +29,26 @@ class TerminalPbm : public Terminal
        public:
                TerminalPbm();
 
+               /*!
+                * \brief フォントのサイズを設定する
+                * \param size 設定するフォントのサイズ
+                */
                void setFontSize(int size);
+               /*!
+                * \brief フォントのサイズを得る
+                * \return フォントのサイズ
+                */
                int fontSize() const;
 
+               /*!
+                * \brief モードを設定する
+                * \param mode 設定するモード
+                */
                void setMode(int mode);
+               /*!
+                * \brief モードを得る
+                * \return モード
+                */
                int mode() const;
 
                //! フォントのサイズ
index f63d6b6..55f9d84 100644 (file)
@@ -20,3 +20,6 @@ foreach (test_file ${test_file_list})
   get_filename_component(filename ${test_file} NAME_WE)
   add_test(${filename} opttests ${filename})
 endforeach (test_file)
+
+add_subdirectory(style)
+add_subdirectory(terminal)
diff --git a/tests/opt/style/CMakeLists.txt b/tests/opt/style/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4664fb6
--- /dev/null
@@ -0,0 +1,18 @@
+include(${QT_USE_FILE})
+include_directories(../../../src/opt/style)
+
+set(test_file_list
+       stylefilltest.cpp
+)
+create_test_sourcelist(opt_style_tests optstyletests.cpp ${test_file_list})
+
+set(opt_style_file_list
+       ../../../src/opt/style/stylefill.cpp
+)
+add_executable(optstyletests ${opt_style_tests} ${opt_style_file_list})
+target_link_libraries(optstyletests ${QT_LIBRARIES})
+
+foreach (test_file ${test_file_list})
+  get_filename_component(filename ${test_file} NAME_WE)
+  add_test(${filename} optstyletests ${filename})
+endforeach (test_file)
diff --git a/tests/opt/style/stylefilltest.cpp b/tests/opt/style/stylefilltest.cpp
new file mode 100644 (file)
index 0000000..550a6ee
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Cueplot: a GUI front-end to gnuplot
+ * Copyright (C) 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, 
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "stylefill.h"
+
+#include <QtCore/QString>
+
+int stylefilltest(int, char *[])
+{
+       StyleFill styleFill;
+       if (!styleFill.isEmpty()) {
+               return 1;
+       }
+       if (!styleFill.isBorder()) {
+               return 1;
+       }
+       if (styleFill.command() != "set style fill empty border") {
+               return 1;
+       }
+       styleFill.setSolid();
+       if (styleFill.command() != "set style fill solid 1 border") {
+               return 1;
+       }
+       styleFill.setDensity(0.25);
+       if (styleFill.command() != "set style fill solid 0.25 border") {
+               return 1;
+       }
+       styleFill.setPattern();
+       if (styleFill.command() != "set style fill pattern 0 border") {
+               return 1;
+       }
+       styleFill.setPattern(2);
+       if (styleFill.command() != "set style fill pattern 2 border") {
+               return 1;
+       }
+       styleFill.setBorder(false);
+       if (styleFill.command() != "set style fill pattern 2 noborder") {
+               return 1;
+       }
+       styleFill.setLineType(2);
+       if (styleFill.command() != "set style fill pattern 2 noborder") {
+               return 1;
+       }
+       styleFill.setBorder(true);
+       if (styleFill.command() != "set style fill pattern 2 border 2") {
+               return 1;
+       }
+       return 0;
+}
diff --git a/tests/opt/terminal/CMakeLists.txt b/tests/opt/terminal/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f211be9
--- /dev/null
@@ -0,0 +1,23 @@
+include(${QT_USE_FILE})
+include_directories(../../../src/opt/terminal)
+
+set(test_file_list
+               terminalpbmtest.cpp
+)
+create_test_sourcelist(opt_terminal_tests
+               optterminaltests.cpp ${test_file_list}
+)
+
+set(opt_terminal_file_list
+       ../../../src/opt/terminal.cpp
+       ../../../src/opt/terminal/terminalpbm.cpp
+)
+add_executable(optterminaltests
+               ${opt_terminal_tests} ${opt_terminal_file_list}
+)
+target_link_libraries(optterminaltests ${QT_LIBRARIES})
+
+foreach (test_file ${test_file_list})
+  get_filename_component(filename ${test_file} NAME_WE)
+  add_test(${filename} optterminaltests ${filename})
+endforeach (test_file)
diff --git a/tests/opt/terminal/terminalpbmtest.cpp b/tests/opt/terminal/terminalpbmtest.cpp
new file mode 100644 (file)
index 0000000..a44fd8b
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Cueplot: a GUI front-end to gnuplot
+ * Copyright (C) 2009 Muneyuki Noguchi <nogu@users.sourceforge.jp>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, 
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "terminalpbm.h"
+
+#include <cstring> // strcmp()
+
+int terminalpbmtest(int, char *[])
+{
+       TerminalPbm terminalPbm;
+       if (terminalPbm.command() != "set terminal pbm small monochrome") {
+               return 1;
+       }
+       terminalPbm.setFontSize(0);
+       if (terminalPbm.command() != "set terminal pbm small monochrome") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::FONT_SIZE[0], "small")) {
+               return 1;
+       }
+       terminalPbm.setFontSize(1);
+       if (terminalPbm.command() != "set terminal pbm medium monochrome") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::FONT_SIZE[1], "medium")) {
+               return 1;
+       }
+       terminalPbm.setFontSize(2);
+       if (terminalPbm.command() != "set terminal pbm large monochrome") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::FONT_SIZE[2], "large")) {
+               return 1;
+       }
+       terminalPbm.setMode(0);
+       if (terminalPbm.command() != "set terminal pbm large monochrome") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::MODE[0], "monochrome")) {
+               return 1;
+       }
+       terminalPbm.setMode(1);
+       if (terminalPbm.command() != "set terminal pbm large gray") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::MODE[1], "gray")) {
+               return 1;
+       }
+       terminalPbm.setMode(2);
+       if (terminalPbm.command() != "set terminal pbm large color") {
+               return 1;
+       }
+       if (std::strcmp(TerminalPbm::MODE[2], "color")) {
+               return 1;
+       }
+       return 0;
+}