diff --git a/.github/workflows/test-storage-cache.yml b/.github/workflows/test-storage-cache.yml new file mode 100644 index 000000000..899e0dac1 --- /dev/null +++ b/.github/workflows/test-storage-cache.yml @@ -0,0 +1,61 @@ +--- +name: Test Storage/Cache + +# yamllint disable-line rule:truthy +on: + pull_request: + paths: + - 'Storage/Cache/**' + - '.github/workflows/test-storage-cache.yml' + push: + paths: + - 'Storage/Cache/**' + - '.github/workflows/test-storage-cache.yml' + +jobs: + + Compile: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Compile + uses: fx31337/mql-compile-action@master + with: + init-platform: true + path: 'Storage/Cache/tests' + verbose: true + - name: Print compiled files + run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' + shell: powershell + - name: Upload artifacts (MQL4) + uses: actions/upload-artifact@v2 + with: + name: files-ex4 + path: '**/*.ex4' + - name: Upload artifacts (MQL5) + uses: actions/upload-artifact@v2 + with: + name: files-ex5 + path: '**/*.ex5' + + Tests-MQL4: + defaults: + run: + shell: bash + working-directory: Storage/Cache/tests + needs: Compile + runs-on: ubuntu-latest + strategy: + matrix: + test: + - ObjectsCache.test + steps: + - uses: actions/download-artifact@v2 + with: + name: files-ex4 + - name: Run ${{ matrix.test }} + uses: fx31337/mql-tester-action@master + with: + Script: ${{ matrix.test }} + RunOnError: show_logs 200 + timeout-minutes: 10 diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 253eb4c95..992478f9e 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -29,7 +29,7 @@ // Includes. #include "../Indicator/Indicator.h" -#include "../Storage/ObjectsCache.h" +#include "../Storage/Cache/ObjectsCache.h" #include "Price/Indi_MA.h" #include "Indi_PriceFeeder.mqh" diff --git a/Storage/ObjectsCache.h b/Storage/Cache/ObjectsCache.h similarity index 98% rename from Storage/ObjectsCache.h rename to Storage/Cache/ObjectsCache.h index 1b47c51cc..132fbef1c 100644 --- a/Storage/ObjectsCache.h +++ b/Storage/Cache/ObjectsCache.h @@ -30,7 +30,7 @@ #endif // Includes. -#include "../Storage/Dict/DictStruct.h" +#include "../../Storage/Dict/DictStruct.h" /** * Makes DictStruct object pointers to be deleted at the end. diff --git a/Storage/Cache/tests/Makefile b/Storage/Cache/tests/Makefile new file mode 100644 index 000000000..e792364f0 --- /dev/null +++ b/Storage/Cache/tests/Makefile @@ -0,0 +1,12 @@ +CC := g++ # C++ compiler +CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags +SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory +OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files + +all: $(OBJS) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -v $(OBJS) diff --git a/Storage/Cache/tests/ObjectsCache.test.cpp b/Storage/Cache/tests/ObjectsCache.test.cpp new file mode 100644 index 000000000..3f5d792fc --- /dev/null +++ b/Storage/Cache/tests/ObjectsCache.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, EA31337 Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/* + * This file 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 . + */ + +/** + * @file + * Test C++ compilation of ObjectsCache class. + */ + +// Includes. +#include "../ObjectsCache.h" + +int main(int argc, char **argv) { + + // @todo: Add more tests. + // ... + + return 0; +} diff --git a/Storage/Cache/tests/ObjectsCache.test.mq4 b/Storage/Cache/tests/ObjectsCache.test.mq4 new file mode 100644 index 000000000..47374a5de --- /dev/null +++ b/Storage/Cache/tests/ObjectsCache.test.mq4 @@ -0,0 +1,28 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, EA31337 Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/* + * This file 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 . + */ + +/** + * @file + * Test functionality of ObjectsCache class. + */ + +// Includes. +#include "ObjectsCache.test.mq5" diff --git a/Storage/Cache/tests/ObjectsCache.test.mq5 b/Storage/Cache/tests/ObjectsCache.test.mq5 new file mode 100644 index 000000000..b0ec18056 --- /dev/null +++ b/Storage/Cache/tests/ObjectsCache.test.mq5 @@ -0,0 +1,40 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, EA31337 Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/* + * This file 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 . + */ + +/** + * @file + * Test functionality of ObjectsCache class. + */ + +// Includes. +#include "../../../Test.mqh" +#include "../ObjectsCache.h" + +/** + * Implements OnInit(). + */ +int OnInit() { + + // @todo: Add more tests. + // ... + + return (GetLastError() > 0 ? INIT_FAILED : INIT_SUCCEEDED); +} diff --git a/Storage/ValueStorage.applied_price.h b/Storage/ValueStorage.applied_price.h index bb752a5b5..bb539190d 100644 --- a/Storage/ValueStorage.applied_price.h +++ b/Storage/ValueStorage.applied_price.h @@ -26,7 +26,7 @@ // Includes. #include "../Chart.struct.h" -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" // Forward declarations. diff --git a/Storage/ValueStorage.price_median.h b/Storage/ValueStorage.price_median.h index 890ffee3e..3e0e62d5c 100644 --- a/Storage/ValueStorage.price_median.h +++ b/Storage/ValueStorage.price_median.h @@ -28,7 +28,7 @@ class IndicatorBase; // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.price_typical.h b/Storage/ValueStorage.price_typical.h index fe99eb869..8f6609ba0 100644 --- a/Storage/ValueStorage.price_typical.h +++ b/Storage/ValueStorage.price_typical.h @@ -25,7 +25,7 @@ */ // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.price_weighted.h b/Storage/ValueStorage.price_weighted.h index 91029acc4..38b6aa411 100644 --- a/Storage/ValueStorage.price_weighted.h +++ b/Storage/ValueStorage.price_weighted.h @@ -25,7 +25,7 @@ */ // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.spread.h b/Storage/ValueStorage.spread.h index 17510321e..ee2e1cf3c 100644 --- a/Storage/ValueStorage.spread.h +++ b/Storage/ValueStorage.spread.h @@ -25,7 +25,7 @@ */ // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.tick_volume.h b/Storage/ValueStorage.tick_volume.h index f2f6d699b..cad534e28 100644 --- a/Storage/ValueStorage.tick_volume.h +++ b/Storage/ValueStorage.tick_volume.h @@ -25,7 +25,7 @@ */ // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.time.h b/Storage/ValueStorage.time.h index c2bdf2bf1..0f73a3b04 100644 --- a/Storage/ValueStorage.time.h +++ b/Storage/ValueStorage.time.h @@ -26,7 +26,7 @@ // Includes. #include "../Util.h" -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/Storage/ValueStorage.volume.h b/Storage/ValueStorage.volume.h index 17072e40e..e68f96e82 100644 --- a/Storage/ValueStorage.volume.h +++ b/Storage/ValueStorage.volume.h @@ -25,7 +25,7 @@ */ // Includes. -#include "ObjectsCache.h" +#include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" /** diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index b3e1d303c..8c35e391a 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -86,7 +86,7 @@ struct IndicatorParams; #include "../RegistryBinary.mqh" #include "../Report.mqh" #include "../Storage/Objects.h" -#include "../Storage/ObjectsCache.h" +#include "../Storage/Cache/ObjectsCache.h" // #include "../SVG.mqh" // @removeme #include "../Session.mqh" #include "../SetFile.mqh"