OSDN Git Service

M tests/CMakeLists.txt: add a subdirectory
authornogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Mon, 16 Mar 2009 21:14:07 +0000 (21:14 +0000)
committernogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Mon, 16 Mar 2009 21:14:07 +0000 (21:14 +0000)
A    tests/command: mkdir
A    tests/command/FitTest.cpp: add tests for the Fit class
A    tests/command/CMakeLists.txt: add tests for the Fit class
M    doc/api/Doxyfile: set SHORT_NAMES to YES
M    src/opt/Angles.h: add comments
M    src/gui/PlotOptionDialog.h: correct a comment
M    src/command/Fit.cpp: init isParameterFile_ in a constructor and remove unnecessary spaces
M    src/command/Fit.h: add comments
M    src/command/PlotRange.cpp: add a space if needed
M    src/command/PlotModifier.cpp: add a space if needed

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

doc/api/Doxyfile
src/command/Fit.cpp
src/command/Fit.h
src/command/PlotModifier.cpp
src/command/PlotRange.cpp
src/gui/PlotOptionDialog.h
src/opt/Angles.h
tests/CMakeLists.txt
tests/command/CMakeLists.txt [new file with mode: 0644]
tests/command/FitTest.cpp [new file with mode: 0644]

index 66f293d..a50af7a 100644 (file)
@@ -128,7 +128,7 @@ STRIP_FROM_INC_PATH    =
 # (but less readable) file names. This can be useful is your file systems 
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
-SHORT_NAMES            = NO
+SHORT_NAMES            = YES
 
 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
 # will interpret the first line (until the first dot) of a JavaDoc-style 
index abbf51c..7afead7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007, 2008 Muneyuki Noguchi
+ * Copyright (C) 2007, 2008, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -20,7 +20,7 @@
 
 const double Fit::DEFAULT_FIT_LIMIT = 1e-5;
 
-Fit::Fit() : functionName_("f(x)"),
+Fit::Fit() : functionName_("f(x)"), isParameterFile_(true),
        fitLimit_(DEFAULT_FIT_LIMIT), fitMaxIter_(DEFAULT_FIT_MAX_ITER)
 {
 }
@@ -135,8 +135,8 @@ QString Fit::command() const
                commandList << "FIT_MAXITER = " + QString::number(fitMaxIter_);
        }
        commandList << functionName_ + '=' + function_;
-       QString str = "fit " + range_.option() + ' ' + functionName_ + " '" 
-               + dataFile_ + "' " + dataFileModifier_.option() + " via ";
+       QString str = "fit " + range_.option() + functionName_ + " '" 
+               + dataFile_ + "' " + dataFileModifier_.option() + "via ";
        if (isParameterFile_) {
                str += '\'' + parameterFile_ + '\'';
        } else {
index f39fa27..efc81ea 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -32,34 +32,114 @@ class Fit : public Command
        public:
                Fit();
 
+               /*!
+                * \brief フィッティングする範囲を設定する
+                * \param range フィッティングする設定する範囲
+                */
                void setRange(const FitRange &range);
+               /*!
+                * \brief フィッティングする範囲を得る
+                * \return フィッティングする範囲
+                */
                const FitRange &range() const;
 
+               /*!
+                * \brief フィッティングに用いる関数の名前を設定する
+                * \param functionName フィッティングに用いる関数の名前
+                */
                void setFunctionName(const QString &functionName);
+               /*!
+                * \brief フィッティングに用いる関数の名前を得る
+                * \return フィッティングに用いる関数の名前
+                */
                const QString &functionName() const;
 
+               /*!
+                * \brief フィッティングに用いる関数の定義を設定する
+                * \param function フィッティングに用いる関数の定義
+                */
                void setFunction(const QString &function);
+               /*!
+                * \brief フィッティングに用いる関数の定義を得る
+                * \return フィッティングに用いる関数の定義
+                */
                const QString &function() const;
 
+               /*!
+                * \brief フィッティングに用いるデータファイルの名前を設定する
+                * \param file フィッティングに用いるデータファイルの名前
+                */
                void setDataFile(const QString &file);
+               /*!
+                * \brief フィッティングに用いるデータファイルの名前を得る
+                * \return フィッティングに用いるデータファイルの名前
+                */
                const QString &dataFile() const;
 
+               /*!
+                * \brief データファイルの修飾子を設定する
+                * \param mod 設定するデータファイルの修飾子
+                */
                void setDataFileModifier(const FitModifier &mod);
+               /*!
+                * \brief データファイルの修飾子を得る
+                * \return データファイルの修飾子
+                */
                const FitModifier &dataFileModifier() const;
 
+               /*!
+                * \brief ファイルでパラメータを指定するかどうかを設定する
+                * \param isFile ファイルでパラメータを指定するかどうか
+                */
                void setParameterFile(bool isFile);
+               /*!
+                * \brief ファイルでパラメータを指定するかどうかを返す
+                * \return ファイルでパラメータを指定するならば true
+                */
                bool isParameterFile() const;
 
+               /*!
+                * \brief パラメータファイルの名前を設定する
+                * \param file 設定するパラメータファイルの名前
+                */
                void setParameterFile(const QString &file);
+               /*!
+                * \brief パラメータファイルの名前を得る
+                * \return パラメータファイルの名前
+                */
                const QString &parameterFile() const;
 
+               /*!
+                * \brief パラメータ変数の名前を設定する
+                * \return 設定するパラメータ変数の名前
+                */
                void setVariable(const QStringList &var);
+               /*!
+                * \brief パラメータ変数の名前を設定する
+                * \return パラメータ変数の名前
+                */
                const QStringList &variable() const;
 
+               /*!
+                * \brief フィッティングの限界を設定する
+                * \param limit 設定するフィッティングの限界
+                */
                void setFitLimit(double limit);
+               /*!
+                * \brief フィッティングの限界を得る
+                * \return フィッティングの限界
+                */
                double fitLimit() const;
 
+               /*!
+                * \brief フィッティングの最大繰り返し数を指定する
+                * \param iter 設定するフィッティングの最大繰り返し数
+                */
                void setFitMaxIter(int iter);
+               /*!
+                * \brief フィッティングの最大繰り返し数を得る
+                * \return フィッティングの最大繰り返し数
+                */
                int fitMaxIter() const;
 
                QString command() const;
index 6db9aba..ad769ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -215,5 +215,8 @@ QString PlotModifier::option() const
        if (smooth_ >= 0) {
                str += "smooth " + SMOOTH[smooth_];
        }
+       if (!str.isEmpty()) {
+               str += ' ';
+       }
        return str;
 }
index 5f16a9b..03785ca 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -86,5 +86,8 @@ QString PlotRange::option() const
                }
                str += ']';
        }
+       if (!str.isEmpty()) {
+               str += ' ';
+       }
        return str;
 }
index ccf6d4f..40b3aae 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007, 2008 Muneyuki Noguchi
+ * Copyright (C) 2007, 2008, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -41,7 +41,7 @@ class PlotOptionDialog : public QDialog
 
                /*!
                 * \brief Plot クラスのオブジェクトのリストを設定する
-                * \param plot 設定するオブジェクト
+                * \param list 設定するオブジェクト
                 */
                void setPlot(const QList<Plot> &list);
                /*!
index 0fb9d39..e9ff3f5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Cueplot: a GUI front-end to gnuplot
- * Copyright (C) 2007 Muneyuki Noguchi
+ * Copyright (C) 2007, 2009 Muneyuki Noguchi
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -29,7 +29,15 @@ class Angles : public Option
        public:
                Angles();
 
+               /*!
+                * \brief 角度の単位を度にするかどうかを設定する
+                * \param degrees 角度の単位を度にするかどうか
+                */
                void setDegrees(bool degrees);
+               /*!
+                * \brief 角度の単位を度にするかどうかを得る
+                * \return 角度の単位が度ならば true
+                */
                bool isDegrees() const;
 
                QString command() const;
index 0074091..5554490 100644 (file)
@@ -1 +1,2 @@
+add_subdirectory(command)
 add_subdirectory(opt)
diff --git a/tests/command/CMakeLists.txt b/tests/command/CMakeLists.txt
new file mode 100644 (file)
index 0000000..467cbf1
--- /dev/null
@@ -0,0 +1,23 @@
+include(${QT_USE_FILE})
+include_directories(../../src/command)
+
+set(test_file_list FitTest.cpp)
+create_test_sourcelist(command_tests CommandTests.cpp ${test_file_list})
+
+set(command_file_list
+       ../../src/command/Fit.cpp
+       ../../src/command/FitModifier.cpp
+       ../../src/command/FitRange.cpp
+       ../../src/command/Plot.cpp
+       ../../src/command/PlotModifier.cpp
+       ../../src/command/PlotRange.cpp
+       ../../src/command/PlotStyle.cpp
+       ../../src/command/PlotTitle.cpp
+)
+add_executable(CommandTests ${command_tests} ${command_file_list})
+target_link_libraries(CommandTests ${QT_LIBRARIES})
+
+foreach (test_file ${test_file_list})
+  get_filename_component(filename ${test_file} NAME_WE)
+  add_test(${filename} CommandTests ${filename})
+endforeach (test_file)
diff --git a/tests/command/FitTest.cpp b/tests/command/FitTest.cpp
new file mode 100644 (file)
index 0000000..ec69ea3
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Cueplot: a GUI front-end to gnuplot
+ * Copyright (C) 2009 Muneyuki Noguchi
+ *
+ * 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 "Fit.h"
+#include <QtCore/QString>
+#include <cstdlib> // exit()
+
+static void test_init(Fit &fit)
+{
+       if (fit.functionName() != "f(x)") {
+               exit(1);
+       }
+       if (!fit.isParameterFile()) {
+               exit(2);
+       }
+       fit.setFunction("ax+b");
+       fit.setDataFile("foo");
+       fit.setParameterFile(QString("bar"));
+       if (fit.command() != "f(x)=ax+b\nfit f(x) 'foo' via 'bar'") {
+               exit(3);
+       }
+}
+
+static void test_variable(Fit &fit)
+{
+       QStringList list;
+       list << "a" << "b";
+       fit.setVariable(list);
+       fit.setParameterFile(false);
+       if (fit.isParameterFile()) {
+               exit(4);
+       }
+       if (fit.command() != "f(x)=ax+b\nfit f(x) 'foo' via a,b") {
+               exit(5);
+       }
+}
+
+static void test_function_name(Fit &fit)
+{
+       fit.setFunctionName("g(x)");
+       if (fit.functionName() != "g(x)") {
+               exit(6);
+       }
+       if (fit.command() != "g(x)=ax+b\nfit g(x) 'foo' via a,b") {
+               exit(7);
+       }
+}
+
+int FitTest(int, char *[])
+{
+       Fit fit;
+       test_init(fit);
+       test_variable(fit);
+       test_function_name(fit);
+       return 0;
+}