trackler 2.0.5.13 → 2.0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/.travis.yml +1 -0
- data/common/bin/check_required_files_present +55 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dpr +60 -0
- data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dproj +176 -0
- data/tracks/pascal/exercises/Hello-World/uHelloWorldExample.pas +24 -0
- data/tracks/pascal/exercises/Hello-World/uTestHelloWorld.pas +65 -0
- data/tracks/pascal/exercises/allergies/AllergyTests.dpr +60 -0
- data/tracks/pascal/exercises/allergies/AllergyTests.dproj +176 -0
- data/tracks/pascal/exercises/allergies/uAllergiesExample.pas +67 -0
- data/tracks/pascal/exercises/allergies/uAllergyTests.pas +177 -0
- data/tracks/pascal/exercises/bank-account/BankAccountTests.dpr +60 -0
- data/tracks/pascal/exercises/bank-account/BankAccountTests.dproj +176 -0
- data/tracks/pascal/exercises/bank-account/uBankAccountExample.pas +96 -0
- data/tracks/pascal/exercises/bank-account/uBankAccountTests.pas +140 -0
- data/tracks/pascal/exercises/beer-song/BeerSongTests.dpr +60 -0
- data/tracks/pascal/exercises/beer-song/BeerSongTests.dproj +176 -0
- data/tracks/pascal/exercises/beer-song/uBeerSongExample.pas +45 -0
- data/tracks/pascal/exercises/beer-song/uBeerSongTests.pas +84 -0
- data/tracks/pascal/exercises/binary-search/BinarySearchTest.dpr +60 -0
- data/tracks/pascal/exercises/binary-search/BinarySearchTest.dproj +176 -0
- data/tracks/pascal/exercises/binary-search/uBinarySearchExample.pas +40 -0
- data/tracks/pascal/exercises/binary-search/uBinarySearchTest.pas +132 -0
- data/tracks/pascal/exercises/bob/BobTests.dpr +60 -0
- data/tracks/pascal/exercises/bob/BobTests.dproj +176 -0
- data/tracks/pascal/exercises/bob/uBobExample.pas +47 -0
- data/tracks/pascal/exercises/bob/uBobTests.pas +180 -0
- data/tracks/pascal/exercises/book-store/BookStoreTests.dpr +60 -0
- data/tracks/pascal/exercises/book-store/BookStoreTests.dproj +176 -0
- data/tracks/pascal/exercises/book-store/uBookStoreExample.pas +144 -0
- data/tracks/pascal/exercises/book-store/uBookStoreTests.pas +56 -0
- data/tracks/pascal/exercises/bowling/BowlingTests.dpr +60 -0
- data/tracks/pascal/exercises/bowling/BowlingTests.dproj +176 -0
- data/tracks/pascal/exercises/bowling/uBowlingExample.pas +105 -0
- data/tracks/pascal/exercises/bowling/uBowlingTests.pas +101 -0
- data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dpr +60 -0
- data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dproj +176 -0
- data/tracks/pascal/exercises/circular-buffer/uCircularBufferExample.pas +72 -0
- data/tracks/pascal/exercises/circular-buffer/uCircularBufferTests.pas +249 -0
- data/tracks/pascal/exercises/clock/ClockTest.dpr +60 -0
- data/tracks/pascal/exercises/clock/ClockTest.dproj +176 -0
- data/tracks/pascal/exercises/clock/uClockExample.pas +54 -0
- data/tracks/pascal/exercises/clock/uClockTest.pas +157 -0
- data/tracks/pascal/exercises/etl/ETLtests.dpr +60 -0
- data/tracks/pascal/exercises/etl/ETLtests.dproj +176 -0
- data/tracks/pascal/exercises/etl/uETLexample.pas +25 -0
- data/tracks/pascal/exercises/etl/uETLtests.pas +191 -0
- data/tracks/pascal/exercises/hamming/Hamming.dpr +60 -0
- data/tracks/pascal/exercises/hamming/Hamming.dproj +176 -0
- data/tracks/pascal/exercises/hamming/uHammingExample.pas +24 -0
- data/tracks/pascal/exercises/hamming/uHammingTests.pas +165 -0
- data/tracks/pascal/exercises/leap/LeapTest.dpr +60 -0
- data/tracks/pascal/exercises/leap/LeapTest.dproj +176 -0
- data/tracks/pascal/exercises/leap/uLeapExample.pas +17 -0
- data/tracks/pascal/exercises/leap/uLeapTests.pas +81 -0
- data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dpr +60 -0
- data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dproj +176 -0
- data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountExample.pas +72 -0
- data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountTest.pas +190 -0
- data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dpr +60 -0
- data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dproj +176 -0
- data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersExample.pas +34 -0
- data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersTest.pas +48 -0
- data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dpr +60 -0
- data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dproj +176 -0
- data/tracks/pascal/exercises/phone-number/uPhoneNumberExample.pas +102 -0
- data/tracks/pascal/exercises/phone-number/uPhoneNumberTests.pas +138 -0
- data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +1 -1
- data/tracks/ruby/Gemfile +0 -1
- data/tracks/ruby/Makefile +2 -1
- data/tracks/ruby/Rakefile +3 -0
- data/tracks/ruby/exercises/simple-linked-list/.meta/.version +1 -0
- data/tracks/ruby/exercises/simple-linked-list/example.rb +39 -48
- data/tracks/ruby/exercises/simple-linked-list/simple_linked_list_test.rb +99 -125
- data/tracks/ruby/exercises/wordy/.meta/.version +1 -0
- data/tracks/ruby/exercises/wordy/example.rb +4 -0
- data/tracks/ruby/exercises/wordy/example.tt +17 -0
- data/tracks/ruby/exercises/wordy/wordy_test.rb +66 -35
- data/tracks/ruby/lib/wordy_cases.rb +67 -0
- data/tracks/ruby/test/wordy_cases_test.rb +102 -0
- data/tracks/scala/config.json +7 -1
- data/tracks/scala/exercises/connect/{README.md → HINTS.md} +1 -12
- data/tracks/scala/exercises/connect/build.sbt +2 -2
- metadata +73 -3
@@ -0,0 +1,180 @@
|
|
1
|
+
unit uBobTests;
|
2
|
+
|
3
|
+
interface
|
4
|
+
uses
|
5
|
+
DUnitX.TestFramework;
|
6
|
+
|
7
|
+
type
|
8
|
+
|
9
|
+
[TestFixture]
|
10
|
+
BobTests = class(TObject)
|
11
|
+
public
|
12
|
+
[Test]
|
13
|
+
[Ignore]
|
14
|
+
procedure Stating_something;
|
15
|
+
|
16
|
+
[Test]
|
17
|
+
[Ignore]
|
18
|
+
procedure Shouting;
|
19
|
+
|
20
|
+
[Test]
|
21
|
+
[Ignore]
|
22
|
+
procedure Asking_a_question;
|
23
|
+
|
24
|
+
[Test]
|
25
|
+
[Ignore]
|
26
|
+
procedure Asking_a_question_with_a_trailing_space;
|
27
|
+
|
28
|
+
[Test]
|
29
|
+
[Ignore]
|
30
|
+
procedure Asking_a_numeric_question;
|
31
|
+
|
32
|
+
[Test]
|
33
|
+
[Ignore]
|
34
|
+
procedure Talking_forcefully;
|
35
|
+
|
36
|
+
[Test]
|
37
|
+
[Ignore]
|
38
|
+
procedure Using_acronyms_in_regular_search;
|
39
|
+
|
40
|
+
[Test]
|
41
|
+
[Ignore]
|
42
|
+
procedure Forceful_questions;
|
43
|
+
|
44
|
+
[Test]
|
45
|
+
[Ignore]
|
46
|
+
procedure Shouting_numbers;
|
47
|
+
|
48
|
+
[Test]
|
49
|
+
[Ignore]
|
50
|
+
procedure Only_numbers;
|
51
|
+
|
52
|
+
[Test]
|
53
|
+
[Ignore]
|
54
|
+
procedure Question_with_only_numbers;
|
55
|
+
|
56
|
+
[Test]
|
57
|
+
[Ignore]
|
58
|
+
procedure Shouting_with_special_characters;
|
59
|
+
|
60
|
+
[Test]
|
61
|
+
[Ignore]
|
62
|
+
procedure Shouting_with_no_exclamation_mark;
|
63
|
+
|
64
|
+
[Test]
|
65
|
+
[Ignore]
|
66
|
+
procedure Statement_containing_question_mark;
|
67
|
+
|
68
|
+
[Test]
|
69
|
+
[Ignore]
|
70
|
+
procedure Prattling_on;
|
71
|
+
|
72
|
+
[Test]
|
73
|
+
[Ignore]
|
74
|
+
procedure Silence;
|
75
|
+
|
76
|
+
[Test]
|
77
|
+
[Ignore]
|
78
|
+
procedure Prolonged_silence;
|
79
|
+
|
80
|
+
[Test]
|
81
|
+
[Ignore]
|
82
|
+
procedure Multiple_line_question;
|
83
|
+
end;
|
84
|
+
|
85
|
+
implementation
|
86
|
+
uses uBob;
|
87
|
+
|
88
|
+
procedure BobTests.Stating_something;
|
89
|
+
begin
|
90
|
+
assert.AreEqual('Whatever.', TBob.Hey('Tom-ay-to, tom-aaaah-to.'));
|
91
|
+
end;
|
92
|
+
|
93
|
+
procedure BobTests.Shouting;
|
94
|
+
begin
|
95
|
+
assert.AreEqual('Whoa, chill out!', TBob.Hey('WATCH OUT!'));
|
96
|
+
end;
|
97
|
+
|
98
|
+
procedure BobTests.Asking_a_question;
|
99
|
+
begin
|
100
|
+
assert.AreEqual('Sure.', TBob.Hey('Does this cryogenic chamber make me look fat?'));
|
101
|
+
end;
|
102
|
+
|
103
|
+
procedure BobTests.Asking_a_question_with_a_trailing_space;
|
104
|
+
begin
|
105
|
+
assert.AreEqual('Sure.', TBob.Hey('Do I like my spacebar too much? '));
|
106
|
+
end;
|
107
|
+
|
108
|
+
procedure BobTests.Asking_a_numeric_question;
|
109
|
+
begin
|
110
|
+
assert.AreEqual('Sure.', TBob.Hey('You are, what, like 15?'));
|
111
|
+
end;
|
112
|
+
|
113
|
+
procedure BobTests.Talking_forcefully;
|
114
|
+
begin
|
115
|
+
assert.AreEqual('Whatever.', TBob.Hey('Let''s go make out behind the gym!'));
|
116
|
+
end;
|
117
|
+
|
118
|
+
procedure BobTests.Using_acronyms_in_regular_search;
|
119
|
+
begin
|
120
|
+
assert.AreEqual('Whatever.', TBob.Hey('It''s OK if you don''t want to go to the DMV.'));
|
121
|
+
end;
|
122
|
+
|
123
|
+
procedure BobTests.Forceful_questions;
|
124
|
+
begin
|
125
|
+
assert.AreEqual('Whoa, chill out!', TBob.Hey('WHAT THE HELL WERE YOU THINKING?'));
|
126
|
+
end;
|
127
|
+
|
128
|
+
procedure BobTests.Shouting_numbers;
|
129
|
+
begin
|
130
|
+
assert.AreEqual('Whoa, chill out!', TBob.Hey('1, 2, 3 GO!'));
|
131
|
+
end;
|
132
|
+
|
133
|
+
procedure BobTests.Only_numbers;
|
134
|
+
begin
|
135
|
+
assert.AreEqual('Whatever.', TBob.Hey('1, 2, 3'));
|
136
|
+
end;
|
137
|
+
|
138
|
+
procedure BobTests.Question_with_only_numbers;
|
139
|
+
begin
|
140
|
+
assert.AreEqual('Sure.', TBob.Hey('4?'));
|
141
|
+
end;
|
142
|
+
|
143
|
+
procedure BobTests.Shouting_with_special_characters;
|
144
|
+
begin
|
145
|
+
assert.AreEqual('Whoa, chill out!', TBob.Hey('ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!'));
|
146
|
+
end;
|
147
|
+
|
148
|
+
procedure BobTests.Shouting_with_no_exclamation_mark;
|
149
|
+
begin
|
150
|
+
assert.AreEqual('Whoa, chill out!', TBob.Hey('I HATE YOU'));
|
151
|
+
end;
|
152
|
+
|
153
|
+
procedure BobTests.Statement_containing_question_mark;
|
154
|
+
begin
|
155
|
+
assert.AreEqual('Whatever.', TBob.Hey('Ending with ? means a question.'));
|
156
|
+
end;
|
157
|
+
|
158
|
+
procedure BobTests.Prattling_on;
|
159
|
+
begin
|
160
|
+
assert.AreEqual('Sure.', TBob.Hey('Wait! Hang on. Are you going to be OK?'));
|
161
|
+
end;
|
162
|
+
|
163
|
+
procedure BobTests.Silence;
|
164
|
+
begin
|
165
|
+
assert.AreEqual('Fine. Be that way!', TBob.Hey(''));
|
166
|
+
end;
|
167
|
+
|
168
|
+
procedure BobTests.Prolonged_silence;
|
169
|
+
begin
|
170
|
+
assert.AreEqual('Fine. Be that way!', TBob.Hey(' '));
|
171
|
+
end;
|
172
|
+
|
173
|
+
procedure BobTests.Multiple_line_question;
|
174
|
+
begin
|
175
|
+
assert.AreEqual('Whatever.', TBob.Hey('Does this cryogenic chamber make me look fat?' + #13#10 + 'no'));
|
176
|
+
end;
|
177
|
+
|
178
|
+
initialization
|
179
|
+
TDUnitX.RegisterTestFixture(BobTests);
|
180
|
+
end.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
program BookStoreTests;
|
2
|
+
|
3
|
+
{$IFNDEF TESTINSIGHT}
|
4
|
+
{$APPTYPE CONSOLE}
|
5
|
+
{$ENDIF}{$STRONGLINKTYPES ON}
|
6
|
+
uses
|
7
|
+
System.SysUtils,
|
8
|
+
{$IFDEF TESTINSIGHT}
|
9
|
+
TestInsight.DUnitX,
|
10
|
+
{$ENDIF }
|
11
|
+
DUnitX.Loggers.Console,
|
12
|
+
DUnitX.Loggers.Xml.NUnit,
|
13
|
+
DUnitX.TestFramework,
|
14
|
+
uBookStoreTests in 'uBookStoreTests.pas',
|
15
|
+
uBookStore in 'uBookStore.pas';
|
16
|
+
|
17
|
+
var
|
18
|
+
runner : ITestRunner;
|
19
|
+
results : IRunResults;
|
20
|
+
logger : ITestLogger;
|
21
|
+
nunitLogger : ITestLogger;
|
22
|
+
begin
|
23
|
+
{$IFDEF TESTINSIGHT}
|
24
|
+
TestInsight.DUnitX.RunRegisteredTests;
|
25
|
+
exit;
|
26
|
+
{$ENDIF}
|
27
|
+
try
|
28
|
+
//Check command line options, will exit if invalid
|
29
|
+
TDUnitX.CheckCommandLine;
|
30
|
+
//Create the test runner
|
31
|
+
runner := TDUnitX.CreateRunner;
|
32
|
+
//Tell the runner to use RTTI to find Fixtures
|
33
|
+
runner.UseRTTI := True;
|
34
|
+
//tell the runner how we will log things
|
35
|
+
//Log to the console window
|
36
|
+
logger := TDUnitXConsoleLogger.Create(true);
|
37
|
+
runner.AddLogger(logger);
|
38
|
+
//Generate an NUnit compatible XML File
|
39
|
+
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
|
40
|
+
runner.AddLogger(nunitLogger);
|
41
|
+
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
|
42
|
+
|
43
|
+
//Run tests
|
44
|
+
results := runner.Execute;
|
45
|
+
if not results.AllPassed then
|
46
|
+
System.ExitCode := EXIT_ERRORS;
|
47
|
+
|
48
|
+
{$IFNDEF CI}
|
49
|
+
//We don't want this happening when running under CI.
|
50
|
+
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
|
51
|
+
begin
|
52
|
+
System.Write('Done.. press <Enter> key to quit.');
|
53
|
+
System.Readln;
|
54
|
+
end;
|
55
|
+
{$ENDIF}
|
56
|
+
except
|
57
|
+
on E: Exception do
|
58
|
+
System.Writeln(E.ClassName, ': ', E.Message);
|
59
|
+
end;
|
60
|
+
end.
|
@@ -0,0 +1,176 @@
|
|
1
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2
|
+
<PropertyGroup>
|
3
|
+
<ProjectGuid>{00833D4E-9C22-4AE8-8578-81B63523F423}</ProjectGuid>
|
4
|
+
<ProjectVersion>15.3</ProjectVersion>
|
5
|
+
<FrameworkType>None</FrameworkType>
|
6
|
+
<MainSource>BookStoreTests.dpr</MainSource>
|
7
|
+
<Base>True</Base>
|
8
|
+
<Config Condition="'$(Config)'==''">Debug</Config>
|
9
|
+
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
10
|
+
<TargetedPlatforms>1</TargetedPlatforms>
|
11
|
+
<AppType>Console</AppType>
|
12
|
+
</PropertyGroup>
|
13
|
+
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
14
|
+
<Base>true</Base>
|
15
|
+
</PropertyGroup>
|
16
|
+
<PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Base)'=='true') or '$(Base_OSX32)'!=''">
|
17
|
+
<Base_OSX32>true</Base_OSX32>
|
18
|
+
<CfgParent>Base</CfgParent>
|
19
|
+
<Base>true</Base>
|
20
|
+
</PropertyGroup>
|
21
|
+
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
|
22
|
+
<Base_Win32>true</Base_Win32>
|
23
|
+
<CfgParent>Base</CfgParent>
|
24
|
+
<Base>true</Base>
|
25
|
+
</PropertyGroup>
|
26
|
+
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
|
27
|
+
<Base_Win64>true</Base_Win64>
|
28
|
+
<CfgParent>Base</CfgParent>
|
29
|
+
<Base>true</Base>
|
30
|
+
</PropertyGroup>
|
31
|
+
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
|
32
|
+
<Cfg_1>true</Cfg_1>
|
33
|
+
<CfgParent>Base</CfgParent>
|
34
|
+
<Base>true</Base>
|
35
|
+
</PropertyGroup>
|
36
|
+
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
|
37
|
+
<Cfg_1_Win32>true</Cfg_1_Win32>
|
38
|
+
<CfgParent>Cfg_1</CfgParent>
|
39
|
+
<Cfg_1>true</Cfg_1>
|
40
|
+
<Base>true</Base>
|
41
|
+
</PropertyGroup>
|
42
|
+
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
|
43
|
+
<Cfg_2>true</Cfg_2>
|
44
|
+
<CfgParent>Base</CfgParent>
|
45
|
+
<Base>true</Base>
|
46
|
+
</PropertyGroup>
|
47
|
+
<PropertyGroup Condition="'$(Base)'!=''">
|
48
|
+
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
|
49
|
+
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
|
50
|
+
<DCC_UnitSearchPath>$(DUnitX);$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
|
51
|
+
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
|
52
|
+
<DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
|
53
|
+
<DCC_E>false</DCC_E>
|
54
|
+
<DCC_N>false</DCC_N>
|
55
|
+
<DCC_S>false</DCC_S>
|
56
|
+
<DCC_F>false</DCC_F>
|
57
|
+
<DCC_K>false</DCC_K>
|
58
|
+
</PropertyGroup>
|
59
|
+
<PropertyGroup Condition="'$(Base_OSX32)'!=''">
|
60
|
+
<DCC_UsePackage>FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;FireDACPgDriver;FireDACODBCDriver;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;DBXInterBaseDriver;DataSnapCommon;xmlrtl;ibxpress;DbxCommonDriver;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;soaprtl;bindengine;bindcompdbx;FMXTee;fmxFireDAC;FireDACADSDriver;CustomIPTransport;FireDAC;dsnap;IndyIPServer;fmxase;IndyCore;IndyIPCommon;CloudService;FireDACIBDriver;FmxTeeUI;inet;fmxobj;FireDACMySQLDriver;inetdbxpress;fmxdae;RESTComponents;FireDACMSAccDriver;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
|
61
|
+
</PropertyGroup>
|
62
|
+
<PropertyGroup Condition="'$(Base_Win32)'!=''">
|
63
|
+
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
|
64
|
+
<VerInfo_Locale>1033</VerInfo_Locale>
|
65
|
+
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
66
|
+
<DCC_UsePackage>frxDB19;L208_r140;FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;AbbreviaVCL;vcldbx;FireDACPgDriver;FireDACODBCDriver;S404_r;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;TeeDB;frx19;vclib;inetdbbde;DBXInterBaseDriver;Tee;DataSnapCommon;vclFireDAC;Rave110VCL;xmlrtl;svnui;ibxpress;DbxCommonDriver;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;MetropolisUILiveTile;O408_r;soaprtl;bindengine;vclactnband;vcldb;bindcompdbx;vcldsnap;bindcompvcl;FMXTee;TeeUI;AsyncPro;vclie;XMLPartner_PR;fmxFireDAC;FireDACADSDriver;vcltouch;CustomIPTransport;G114_R140;vclribbon;VclSmp;FireDAC;dsnap;IndyIPServer;Intraweb;fmxase;vcl;IndyCore;VCLRESTComponents;IndyIPCommon;CloudService;CodeSiteExpressPkg;dsnapcon;FireDACIBDriver;FmxTeeUI;inet;fmxobj;E111_R120;FireDACMySQLDriver;vclx;inetdbxpress;svn;fmxdae;frxe19;RESTComponents;bdertl;FireDACMSAccDriver;adortl;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
|
67
|
+
</PropertyGroup>
|
68
|
+
<PropertyGroup Condition="'$(Base_Win64)'!=''">
|
69
|
+
<DCC_UsePackage>FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;AbbreviaVCL;FireDACPgDriver;FireDACODBCDriver;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;TeeDB;vclib;DBXInterBaseDriver;Tee;DataSnapCommon;vclFireDAC;xmlrtl;ibxpress;DbxCommonDriver;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;MetropolisUILiveTile;O408_r;soaprtl;bindengine;vclactnband;vcldb;bindcompdbx;vcldsnap;bindcompvcl;FMXTee;TeeUI;vclie;fmxFireDAC;FireDACADSDriver;vcltouch;CustomIPTransport;vclribbon;VclSmp;FireDAC;dsnap;IndyIPServer;Intraweb;fmxase;vcl;IndyCore;VCLRESTComponents;IndyIPCommon;CloudService;dsnapcon;FireDACIBDriver;FmxTeeUI;inet;fmxobj;FireDACMySQLDriver;vclx;inetdbxpress;fmxdae;RESTComponents;FireDACMSAccDriver;adortl;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
|
70
|
+
</PropertyGroup>
|
71
|
+
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
72
|
+
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
|
73
|
+
<DCC_DebugDCUs>true</DCC_DebugDCUs>
|
74
|
+
<DCC_Optimize>false</DCC_Optimize>
|
75
|
+
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
76
|
+
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
|
77
|
+
<DCC_RemoteDebug>true</DCC_RemoteDebug>
|
78
|
+
</PropertyGroup>
|
79
|
+
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
|
80
|
+
<DCC_RemoteDebug>false</DCC_RemoteDebug>
|
81
|
+
</PropertyGroup>
|
82
|
+
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
83
|
+
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
|
84
|
+
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
85
|
+
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
86
|
+
<DCC_DebugInformation>0</DCC_DebugInformation>
|
87
|
+
</PropertyGroup>
|
88
|
+
<ItemGroup>
|
89
|
+
<DelphiCompile Include="$(MainSource)">
|
90
|
+
<MainSource>MainSource</MainSource>
|
91
|
+
</DelphiCompile>
|
92
|
+
<DCCReference Include="uBookStoreTests.pas"/>
|
93
|
+
<DCCReference Include="uBookStore.pas"/>
|
94
|
+
<BuildConfiguration Include="Release">
|
95
|
+
<Key>Cfg_2</Key>
|
96
|
+
<CfgParent>Base</CfgParent>
|
97
|
+
</BuildConfiguration>
|
98
|
+
<BuildConfiguration Include="Base">
|
99
|
+
<Key>Base</Key>
|
100
|
+
</BuildConfiguration>
|
101
|
+
<BuildConfiguration Include="Debug">
|
102
|
+
<Key>Cfg_1</Key>
|
103
|
+
<CfgParent>Base</CfgParent>
|
104
|
+
</BuildConfiguration>
|
105
|
+
</ItemGroup>
|
106
|
+
<ProjectExtensions>
|
107
|
+
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
108
|
+
<Borland.ProjectType/>
|
109
|
+
<BorlandProject>
|
110
|
+
<Delphi.Personality>
|
111
|
+
<VersionInfo>
|
112
|
+
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
113
|
+
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
114
|
+
<VersionInfo Name="MajorVer">1</VersionInfo>
|
115
|
+
<VersionInfo Name="MinorVer">0</VersionInfo>
|
116
|
+
<VersionInfo Name="Release">0</VersionInfo>
|
117
|
+
<VersionInfo Name="Build">0</VersionInfo>
|
118
|
+
<VersionInfo Name="Debug">False</VersionInfo>
|
119
|
+
<VersionInfo Name="PreRelease">False</VersionInfo>
|
120
|
+
<VersionInfo Name="Special">False</VersionInfo>
|
121
|
+
<VersionInfo Name="Private">False</VersionInfo>
|
122
|
+
<VersionInfo Name="DLL">False</VersionInfo>
|
123
|
+
<VersionInfo Name="Locale">1033</VersionInfo>
|
124
|
+
<VersionInfo Name="CodePage">1252</VersionInfo>
|
125
|
+
</VersionInfo>
|
126
|
+
<VersionInfoKeys>
|
127
|
+
<VersionInfoKeys Name="CompanyName"/>
|
128
|
+
<VersionInfoKeys Name="FileDescription"/>
|
129
|
+
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
130
|
+
<VersionInfoKeys Name="InternalName"/>
|
131
|
+
<VersionInfoKeys Name="LegalCopyright"/>
|
132
|
+
<VersionInfoKeys Name="LegalTrademarks"/>
|
133
|
+
<VersionInfoKeys Name="OriginalFilename"/>
|
134
|
+
<VersionInfoKeys Name="ProductName"/>
|
135
|
+
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
136
|
+
<VersionInfoKeys Name="Comments"/>
|
137
|
+
<VersionInfoKeys Name="CFBundleName"/>
|
138
|
+
<VersionInfoKeys Name="CFBundleDisplayName"/>
|
139
|
+
<VersionInfoKeys Name="UIDeviceFamily"/>
|
140
|
+
<VersionInfoKeys Name="CFBundleIdentifier"/>
|
141
|
+
<VersionInfoKeys Name="CFBundleVersion"/>
|
142
|
+
<VersionInfoKeys Name="CFBundlePackageType"/>
|
143
|
+
<VersionInfoKeys Name="CFBundleSignature"/>
|
144
|
+
<VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
|
145
|
+
<VersionInfoKeys Name="UISupportedInterfaceOrientations"/>
|
146
|
+
<VersionInfoKeys Name="CFBundleExecutable"/>
|
147
|
+
<VersionInfoKeys Name="CFBundleResourceSpecification"/>
|
148
|
+
<VersionInfoKeys Name="LSRequiresIPhoneOS"/>
|
149
|
+
<VersionInfoKeys Name="CFBundleInfoDictionaryVersion"/>
|
150
|
+
<VersionInfoKeys Name="CFBundleDevelopmentRegion"/>
|
151
|
+
<VersionInfoKeys Name="package"/>
|
152
|
+
<VersionInfoKeys Name="label"/>
|
153
|
+
<VersionInfoKeys Name="versionCode"/>
|
154
|
+
<VersionInfoKeys Name="versionName"/>
|
155
|
+
<VersionInfoKeys Name="persistent"/>
|
156
|
+
<VersionInfoKeys Name="restoreAnyVersion"/>
|
157
|
+
<VersionInfoKeys Name="installLocation"/>
|
158
|
+
<VersionInfoKeys Name="largeHeap"/>
|
159
|
+
<VersionInfoKeys Name="theme"/>
|
160
|
+
</VersionInfoKeys>
|
161
|
+
<Source>
|
162
|
+
<Source Name="MainSource">BookStoreTests.dpr</Source>
|
163
|
+
</Source>
|
164
|
+
</Delphi.Personality>
|
165
|
+
<Deployment/>
|
166
|
+
<Platforms>
|
167
|
+
<Platform value="OSX32">False</Platform>
|
168
|
+
<Platform value="Win32">True</Platform>
|
169
|
+
<Platform value="Win64">False</Platform>
|
170
|
+
</Platforms>
|
171
|
+
</BorlandProject>
|
172
|
+
<ProjectFileVersion>12</ProjectFileVersion>
|
173
|
+
</ProjectExtensions>
|
174
|
+
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
|
175
|
+
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
|
176
|
+
</Project>
|
@@ -0,0 +1,144 @@
|
|
1
|
+
unit uBookStore;
|
2
|
+
|
3
|
+
interface
|
4
|
+
|
5
|
+
type
|
6
|
+
IBasket = interface(IInvokable)
|
7
|
+
['{22B4BAF3-88E6-456D-9DE5-F6BAC743A655}']
|
8
|
+
function Total:extended;
|
9
|
+
end;
|
10
|
+
|
11
|
+
function NewBasket(aBasket: TArray<Integer>): IBasket;
|
12
|
+
|
13
|
+
implementation
|
14
|
+
uses System.SysUtils;
|
15
|
+
|
16
|
+
const
|
17
|
+
seriesBooks = '12345';
|
18
|
+
cNumberOfBooks = 5;
|
19
|
+
cDiscounts: array[1..cNumberOfBooks] of extended = (1.00,
|
20
|
+
0.95,
|
21
|
+
0.90,
|
22
|
+
0.80,
|
23
|
+
0.75);
|
24
|
+
|
25
|
+
type
|
26
|
+
TBasket = class(TInterfacedObject, IBasket)
|
27
|
+
private
|
28
|
+
fSingleBookPrice: extended;
|
29
|
+
fBasket: string;
|
30
|
+
class function Head(inStr: string): string; static;
|
31
|
+
class function Tail(inStr: string): string; static;
|
32
|
+
class function ConvertIntArrayToString(const aIntArray: TArray<Integer>): string; static;
|
33
|
+
function DiscountPercentage(inStr : string): extended;
|
34
|
+
function GroupBasket:TArray<String>;
|
35
|
+
function NumberOfDifferentBooks(inStr : string):integer;
|
36
|
+
public
|
37
|
+
function Total:extended;
|
38
|
+
constructor Create(aBasket: TArray<Integer>);
|
39
|
+
end;
|
40
|
+
|
41
|
+
function NewBasket(aBasket: TArray<Integer>): IBasket;
|
42
|
+
begin
|
43
|
+
result := TBasket.Create(aBasket);
|
44
|
+
end;
|
45
|
+
|
46
|
+
class function TBasket.Head(inStr : string):string;
|
47
|
+
begin
|
48
|
+
result := inStr.Remove(1);
|
49
|
+
end;
|
50
|
+
|
51
|
+
class function TBasket.Tail(inStr : string):string;
|
52
|
+
begin
|
53
|
+
result := inStr.Remove(0,1);
|
54
|
+
end;
|
55
|
+
|
56
|
+
class function TBasket.ConvertIntArrayToString(const aIntArray: TArray<Integer>): string;
|
57
|
+
var arrayItem: integer;
|
58
|
+
begin
|
59
|
+
result := '';
|
60
|
+
if length(aIntArray) > 0 then
|
61
|
+
for arrayItem in aIntArray do
|
62
|
+
result := result + arrayItem.ToString;
|
63
|
+
end;
|
64
|
+
|
65
|
+
constructor TBasket.Create(aBasket: TArray<Integer>);
|
66
|
+
begin
|
67
|
+
fSingleBookPrice := 8;
|
68
|
+
fBasket := ConvertIntArrayToString(aBasket);
|
69
|
+
end;
|
70
|
+
|
71
|
+
function TBasket.GroupBasket:TArray<String>;
|
72
|
+
var lStrArray: TArray<String>;
|
73
|
+
wrkBasket: string;
|
74
|
+
tmpStr : string;
|
75
|
+
thisBook : string;
|
76
|
+
Index : integer;
|
77
|
+
StrCount : integer;
|
78
|
+
begin
|
79
|
+
wrkBasket := fBasket;
|
80
|
+
StrCount := 1;
|
81
|
+
SetLength(lStrArray,StrCount);
|
82
|
+
thisBook := Head(wrkBasket);
|
83
|
+
while wrkBasket.Length > 0 do
|
84
|
+
begin
|
85
|
+
Index := 0;
|
86
|
+
repeat
|
87
|
+
tmpStr := lStrArray[Index];
|
88
|
+
if thisBook.Length > 0 then
|
89
|
+
begin
|
90
|
+
if not tmpStr.Contains(thisBook) then
|
91
|
+
begin
|
92
|
+
tmpStr := tmpStr + thisBook;
|
93
|
+
lStrArray[Index] := tmpStr;
|
94
|
+
wrkBasket := Tail(wrkBasket);
|
95
|
+
thisBook := Head(wrkBasket);
|
96
|
+
end
|
97
|
+
else
|
98
|
+
if (Index = StrCount - 1) then
|
99
|
+
begin
|
100
|
+
inc(StrCount);
|
101
|
+
SetLength(lStrArray,StrCount);
|
102
|
+
end;
|
103
|
+
inc(Index);
|
104
|
+
end;
|
105
|
+
until (Index = StrCount) or wrkBasket.IsEmpty;
|
106
|
+
end;
|
107
|
+
result := lStrArray;
|
108
|
+
end;
|
109
|
+
|
110
|
+
function TBasket.Total:extended;
|
111
|
+
var hpBook : char;
|
112
|
+
totalBooks : integer;
|
113
|
+
subBaskets : TArray<String>;
|
114
|
+
wrkSubBasket: string;
|
115
|
+
subTotal : extended;
|
116
|
+
begin
|
117
|
+
subBaskets := GroupBasket;
|
118
|
+
result := 0;
|
119
|
+
for wrkSubBasket in subBaskets do
|
120
|
+
begin
|
121
|
+
totalBooks := wrkSubBasket.Length;
|
122
|
+
subTotal := totalBooks * (fSingleBookPrice * DiscountPercentage(wrkSubBasket));
|
123
|
+
result := result + subTotal;
|
124
|
+
end;
|
125
|
+
end;
|
126
|
+
|
127
|
+
function TBasket.DiscountPercentage(inStr : string):extended;
|
128
|
+
var numDiffBooks: integer;
|
129
|
+
begin
|
130
|
+
result := 1;
|
131
|
+
numDiffBooks := NumberOfDifferentBooks(inStr);
|
132
|
+
result := CDiscounts[numDiffBooks];
|
133
|
+
end;
|
134
|
+
|
135
|
+
function TBasket.NumberOfDifferentBooks(inStr : string):integer;
|
136
|
+
var Book: char;
|
137
|
+
begin
|
138
|
+
result := 0;
|
139
|
+
for Book in seriesBooks do
|
140
|
+
if inStr.Contains(Book) then
|
141
|
+
inc(result);
|
142
|
+
end;
|
143
|
+
|
144
|
+
end.
|