Mercurial > hg > aimc
changeset 289:6cf55200a199
-Added basic support for unit tests using gtest
-Updated lint scripts to exclude header guard problems
-Made everything lint-friendly
-Added a trivial script to build the Doxygen documentation
author | tomwalters |
---|---|
date | Sat, 20 Feb 2010 21:03:57 +0000 |
parents | 34993448961f |
children | e344ef4898b2 |
files | trunk/SConstruct trunk/build_docs.sh trunk/lint_all.sh trunk/src/Main/aimc.cc trunk/src/Modules/BMM/ModuleGammatone.cc trunk/src/Modules/Output/FileOutputHTK.cc trunk/src/Modules/Output/FileOutputHTK.h trunk/src/Modules/Profile/ModuleSlice_unittest.cc trunk/src/Modules/SSI/ModuleSSI.cc |
diffstat | 9 files changed, 104 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/SConstruct Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/SConstruct Sat Feb 20 21:03:57 2010 +0000 @@ -29,6 +29,29 @@ import os import shutil +# Sources common to every version +common_sources = ['Support/Common.cc', + 'Support/SignalBank.cc', + 'Support/Parameters.cc', + 'Support/Module.cc', + 'Modules/Input/ModuleFileInput.cc', + 'Modules/BMM/ModuleGammatone.cc', + 'Modules/BMM/ModulePZFC.cc', + 'Modules/NAP/ModuleHCL.cc', + 'Modules/Strobes/ModuleParabola.cc', + 'Modules/SAI/ModuleSAI.cc', + 'Modules/SSI/ModuleSSI.cc', + 'Modules/Profile/ModuleSlice.cc', + 'Modules/Features/ModuleGaussians.cc', + 'Modules/Output/FileOutputHTK.cc'] + +# File which contains main() +sources = common_sources + ['Main/aimc.cc'] + +# Test sources +test_sources = ['Modules/Profile/ModuleSlice_unittest.cc'] +test_sources += common_sources + # Define the command-line options for running scons options = Variables() options.Add(BoolVariable('mingw', @@ -48,6 +71,7 @@ # Build products location and executable name build_dir = os.path.join('build', target_platform + '-release') target_executable = 'aimc' +test_executable = 'aimc_tests' # Create build products directory if necessary if not os.path.exists(build_dir): @@ -90,33 +114,14 @@ else: print('Unsupported compiler: ' + compiler) Exit(1) - -# Sources common to every version -common_sources = ['Support/Common.cc', - 'Support/SignalBank.cc', - 'Support/Parameters.cc', - 'Support/Module.cc', - 'Modules/Input/ModuleFileInput.cc', - 'Modules/BMM/ModuleGammatone.cc', - 'Modules/BMM/ModulePZFC.cc', - 'Modules/NAP/ModuleHCL.cc', - 'Modules/Strobes/ModuleParabola.cc', - 'Modules/SAI/ModuleSAI.cc', - 'Modules/SSI/ModuleSSI.cc', - 'Modules/Profile/ModuleSlice.cc', - 'Modules/Features/ModuleGaussians.cc', - 'Modules/Output/FileOutputHTK.cc'] if not target_platform == 'win32': # On windows, utf support is builtin for SimpleIni # but not on other platforms - common_sources += ['Support/ConvertUTF.c'] - -# Choose file which contains main() -sources = common_sources + ['Main/aimc.cc'] + sources += ['Support/ConvertUTF.c'] # Place the build products in the corect place -env.BuildDir('#' + build_dir, '#', duplicate = 0) +env.VariantDir('#' + build_dir, '#', duplicate = 0) # Look for the sources in the correct place env.Append(CPPPATH = '#src') @@ -129,8 +134,22 @@ env.AppendUnique(LIBS = deplibs) -# Set up the builder to build the program +test_env = env +test_libs = ['gtest', 'gtest_main'] +#for depname in test_libs: +# test_env.ParseConfig('pkg-config --cflags --libs ' + depname) +test_env.AppendUnique(LIBPATH = '/usr/local/lib', + CPPPATH = '/usr/local/lib', + LIBS = test_libs) + +# Builder for the main program program = env.Program(target = os.path.join(build_dir, target_executable), source = map(lambda x: '#' + build_dir + '/src/' + x, sources)) +env.Alias(target_executable, os.path.join(build_dir, target_executable)) env.Default(program) + +test = test_env.Program(target = os.path.join(build_dir, test_executable), + source = map(lambda x: '#' + build_dir + '/src/' + x, + test_sources)) +env.Alias('test', os.path.join(build_dir, test_executable))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/build_docs.sh Sat Feb 20 21:03:57 2010 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash +doxygen doc/Doxyfile +
--- a/trunk/lint_all.sh Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/lint_all.sh Sat Feb 20 21:03:57 2010 +0000 @@ -1,3 +1,3 @@ #!/bin/bash -find -E . -iregex ".*\.(h|cc|c)" | grep -v "ConvertUTF" | grep -v "SimpleIni" | xargs lint/cpplint.py +find -E . -iregex ".*\.(h|cc|c)" | grep -v "ConvertUTF" | grep -v "SimpleIni" | xargs lint/cpplint.py --filter=-build/header_guard
--- a/trunk/src/Main/aimc.cc Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/src/Main/aimc.cc Sat Feb 20 21:03:57 2010 +0000 @@ -35,7 +35,7 @@ aimc::Parameters params; aimc::ModuleFileInput input(¶ms); aimc::ModuleGammatone bmm(¶ms); - //aimc::ModulePZFC bmm(¶ms); + // aimc::ModulePZFC bmm(¶ms); aimc::ModuleHCL nap(¶ms); aimc::ModuleParabola strobes(¶ms); aimc::ModuleSAI sai(¶ms);
--- a/trunk/src/Modules/BMM/ModuleGammatone.cc Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/src/Modules/BMM/ModuleGammatone.cc Sat Feb 20 21:03:57 2010 +0000 @@ -148,7 +148,7 @@ * sin(2.0f * cf * M_PI * dt) / exp(b * dt)) / 2.0f; double B14 = -(2.0f * dt * cos(2.0f * cf * M_PI * dt) / exp(b * dt) - 2.0f * sqrt(3 - pow(2.0f, 1.5f)) * dt - * sin(2.0f * cf * M_PI * dt) / exp(b * dt)) / 2.0f;; + * sin(2.0f * cf * M_PI * dt) / exp(b * dt)) / 2.0f; a_[ch][0] = 1.0f; a_[ch][1] = -2.0f * cos(2.0f * cf * M_PI * dt) / exp(b * dt); @@ -165,7 +165,6 @@ b4_[ch][0] = B0; b4_[ch][1] = B14; b4_[ch][2] = B2; - } return true; }
--- a/trunk/src/Modules/Output/FileOutputHTK.cc Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/src/Modules/Output/FileOutputHTK.cc Sat Feb 20 21:03:57 2010 +0000 @@ -47,7 +47,6 @@ file_handle_ = NULL; header_written_ = false; - filename_[0] = '\0'; frame_period_ms_ = 0.0f; } @@ -67,7 +66,6 @@ LOG_ERROR(_T("Couldn't open output file '%s' for writing."), filename); return false; } - strcpy(filename_, filename); sample_count_ = 0; frame_period_ms_ = frame_period_ms; header_written_ = false; @@ -115,7 +113,7 @@ int32_t sample_count = 0; int32_t sample_period = floor(1e4 * period_ms); - int16_t sample_size = num_elements * sizeof(float); + int16_t sample_size = num_elements * sizeof(float); // NOLINT // User-defined coefficients with energy term int16_t parameter_kind = H_USER + H_E;
--- a/trunk/src/Modules/Output/FileOutputHTK.h Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/src/Modules/Output/FileOutputHTK.h Sat Feb 20 21:03:57 2010 +0000 @@ -98,10 +98,6 @@ */ bool header_written_; - /*! \brief Filename - */ - char filename_[PATH_MAX]; - /*! \brief Internal pointer to the output file */ FILE *file_handle_;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/Modules/Profile/ModuleSlice_unittest.cc Sat Feb 20 21:03:57 2010 +0000 @@ -0,0 +1,55 @@ +// Copyright 2010, Thomas Walters +// +// AIM-C: A C++ implementation of the Auditory Image Model +// http://www.acousticscale.org/AIMC +// +// 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 3 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, see <http://www.gnu.org/licenses/>. + +/*! + * \author Thomas Walters <tom@acousticscale.org> + * \date created 2010/02/20 + * \version \$Id$ + */ + +#include <boost/scoped_ptr.hpp> +#include <gtest/gtest.h> + +#include "Support/Parameters.h" +#include "Modules/Profile/ModuleSlice.h" + +namespace aimc { +using boost::scoped_ptr; +class ModuleSliceTest : public ::testing::Test { + protected: + virtual void SetUp() { + slice_.reset(new ModuleSlice(¶meters_)); + } + + // virtual void TearDown() {} + + scoped_ptr<ModuleSlice> slice_; + Parameters parameters_; +}; + +TEST_F(ModuleSliceTest, SetsDefaultParameters) { + EXPECT_EQ(false, parameters_.GetBool("slice.temporal")); + EXPECT_EQ(true, parameters_.GetBool("slice.all")); + EXPECT_EQ(0, parameters_.GetInt("slice.lower_index")); + EXPECT_EQ(1000, parameters_.GetInt("slice.upper_index")); + EXPECT_EQ(false, parameters_.GetBool("slice.normalize")); +} + +TEST_F(ModuleSliceTest, DoesSomethingElse) { +} +} // namespace aimc
--- a/trunk/src/Modules/SSI/ModuleSSI.cc Sat Feb 20 17:56:40 2010 +0000 +++ b/trunk/src/Modules/SSI/ModuleSSI.cc Sat Feb 20 21:03:57 2010 +0000 @@ -33,7 +33,7 @@ module_type_ = "ssi"; module_version_ = "$Id$"; - //do_pitch_cutoff_ = parameters_->DefaultBool("ssi.pitch_cutoff", false); + // do_pitch_cutoff_ = parameters_->DefaultBool("ssi.pitch_cutoff", false); ssi_width_cycles_ = parameters_->DefaultFloat("ssi.width_cycles", 20.0f); }