Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #85 and #87: FL_LOG, FL_BUILD_PATH, and examples #116

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Version 7.0
* The namespace is renamed from `fl` to `fuzzylite`
* The deployment target on OSX is set to 10.15
* The tests use `catch2` as suggested in [#94](https://github.com/fuzzylite/fuzzylite/issues/94)
*
* `FL_LOG` might have different behaviour if used outside of the fuzzylite project. `FL_LOG` does not use the build path to trim the output anymore, instead finds the first instance of `fuzzylite` in the `__FILE__` and trims until there. Fixes [#85](https://github.com/fuzzylite/fuzzylite/issues/85) and [#87](https://github.com/fuzzylite/fuzzylite/issues/87)


Version 6.0
Expand Down
2 changes: 0 additions & 2 deletions fuzzylite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE )
endif()

add_definitions(-DFL_BUILD_PATH="${PROJECT_SOURCE_DIR}") #used to determine FL__FILE__

option(FL_BUILD_SHARED "Build shared library" ON)
option(FL_BUILD_STATIC "Build static library" ON)
if(FL_BUILD_SHARED)
Expand Down
9 changes: 3 additions & 6 deletions fuzzylite/fuzzylite/fuzzylite.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include <memory>
#include <sstream>

#ifndef FL_BUILD_PATH
#define FL_BUILD_PATH ""
#endif

#if defined(_WIN32) || defined(WIN32)
#define FL_WINDOWS
#endif
Expand All @@ -44,8 +40,9 @@
#endif
#endif

#define FL__FILE__ \
std::string(__FILE__).substr(std::string(FL_BUILD_PATH).size())
#define FL__FILE__ \
std::string(__FILE__).substr( \
std::min(std::string::npos, std::string(__FILE__).find("fuzzylite")))

#define FL_LOG_PREFIX FL__FILE__ << " (" << __LINE__ << "):"

Expand Down
12 changes: 11 additions & 1 deletion fuzzylite/test/BenchmarkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ TEST_CASE("Benchmarks run from Console ", "[benchmark][console]") {
}

TEST_CASE("Benchmarks from FLD files", "[benchmark][fld]") {
std::string path = FL_BUILD_PATH "/../examples/";
std::string pathSeparator =
#ifdef FL_WINDOWS
"\\";
#else
"/";
#endif
std::string basePath = std::string(__FILE__).substr(
0,
std::string(__FILE__).find(std::string("fuzzylite") + pathSeparator
+ "test"));
std::string path = basePath + "examples" + pathSeparator;
typedef std::pair<std::string, int> Example;
std::vector<Example> examples;
examples.push_back(Example("mamdani/AllTerms", int(1e4)));
Expand Down
26 changes: 26 additions & 0 deletions fuzzylite/test/fuzzyliteTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
fuzzylite (R), a fuzzy logic control library in C++.
Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>

This file is part of fuzzylite.

fuzzylite is free software: you can redistribute it and/or modify it under
the terms of the FuzzyLite License included with the software.

You should have received a copy of the FuzzyLite License along with
fuzzylite. If not, see <http://www.fuzzylite.com/license/>.

fuzzylite is a registered trademark of FuzzyLite Limited.
*/

#include "fuzzylite/Headers.h"
#include "test/catch.hpp"

namespace fuzzylite {

TEST_CASE("FL__FILE__ ", "[fuzzylite]") {
CHECK(FL__FILE__.find("fuzzylite") == 0);
}

} // namespace fuzzylite