Skip to content

Commit

Permalink
Moves ObjectsCache to Storage/Cache/
Browse files Browse the repository at this point in the history
Adds new tests
  • Loading branch information
kenorb committed Jun 17, 2023
1 parent f2b5321 commit d341334
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 11 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/test-storage-cache.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Indicators/Indi_StdDev.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion Storage/ObjectsCache.h → Storage/Cache/ObjectsCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions Storage/Cache/tests/Makefile
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 36 additions & 0 deletions Storage/Cache/tests/ObjectsCache.test.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test C++ compilation of ObjectsCache class.
*/

// Includes.
#include "../ObjectsCache.h"

int main(int argc, char **argv) {

// @todo: Add more tests.
// ...

return 0;
}
28 changes: 28 additions & 0 deletions Storage/Cache/tests/ObjectsCache.test.mq4
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test functionality of ObjectsCache class.
*/

// Includes.
#include "ObjectsCache.test.mq5"
40 changes: 40 additions & 0 deletions Storage/Cache/tests/ObjectsCache.test.mq5
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

/**
* @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);
}
2 changes: 1 addition & 1 deletion Storage/ValueStorage.applied_price.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Includes.
#include "../Chart.struct.h"
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

// Forward declarations.
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.price_median.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class IndicatorBase;

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.price_typical.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.price_weighted.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.spread.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.tick_volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.time.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Includes.
#include "../Util.h"
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/ValueStorage.volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// Includes.
#include "ObjectsCache.h"
#include "Cache/ObjectsCache.h"
#include "ValueStorage.history.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/CompileTest.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d341334

Please sign in to comment.