From c8a009cb58937242d742e3dd344b024ecb3b56b3 Mon Sep 17 00:00:00 2001 From: Marina Krcek Date: Mon, 12 Nov 2018 17:12:40 +0100 Subject: [PATCH 1/6] Exercise 01 - call function from static library - call function from dynamic library with implib --- exercise/01/app/app.cpp | Bin 0 -> 980 bytes exercise/01/app/app.vcxproj | 195 ++++++++++++++++++++++++++++ exercise/01/app/app.vcxproj.filters | 30 +++++ exercise/01/app/pch.cpp | Bin 0 -> 430 bytes exercise/01/app/pch.h | Bin 0 -> 1262 bytes exercise/01/e01.sln | 25 ++-- 6 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 exercise/01/app/app.cpp create mode 100644 exercise/01/app/app.vcxproj create mode 100644 exercise/01/app/app.vcxproj.filters create mode 100644 exercise/01/app/pch.cpp create mode 100644 exercise/01/app/pch.h diff --git a/exercise/01/app/app.cpp b/exercise/01/app/app.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3db4891dfc2d8a4a578016fde853838473965fd9 GIT binary patch literal 980 zcmbu8%}&BV6ot=L6W?J{7vQEumq>gD7bY%AnPO>DkU;S###dLrduc%;H6~`#&UEJ7 zGvC}h{rnhcprA}kTB_)M(2%)1%~Wd5=z+e{lu^{97OK&g^tM)`vX!3Z&1}yjHmpZh zOOHsIyVZ(u!8=16heJ2_7jYsPLW8FCm}!SNxT^ zjmyziy6TLytQbK}F52q!b>ZiG^Y;m{R)3?-ybh7CEsxb{rPoGhiky2f^gCcR3mVZZ z%g3Va1|>Vqcg48zH?M-6*Ba}Iy{v9i^>qnh>%HG~>UW{iwe#4?TJ{{q1@UvvdYu06 p>Of^nh-MI!I4&F3t;3$i{)59D9H;2=JIv01vJfD(W`ytl{sR7EnV + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111} + Win32Proj + app + 10.0.17134.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Platform)\$(Configuration) + $(Platform)\$(Configuration) + + + true + $(Platform)\$(Configuration) + $(Platform)\$(Configuration) + + + false + $(Platform)\$(Configuration) + $(Platform)\$(Configuration) + + + false + $(Platform)\$(Configuration) + $(Platform)\$(Configuration) + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + + + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + + + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + + + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + + + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + + + + + + + + + + + + + \ No newline at end of file diff --git a/exercise/01/app/app.vcxproj.filters b/exercise/01/app/app.vcxproj.filters new file mode 100644 index 0000000..95c9b51 --- /dev/null +++ b/exercise/01/app/app.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/exercise/01/app/pch.cpp b/exercise/01/app/pch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a38f8a37da858b0e7a4a577210e923c883ac97f3 GIT binary patch literal 430 zcma)(OAdlS5JYQj;vFWsRoUwaJO;ubLXfO} ziM!*RK?b#&)PqF4LX~Q_GVq=g$>^{f<-{7@$r|ykmqm|MwtC_%l{t|TJS9Jpalvn} ztpC7C!Dg_+`-h+El+KlNtsDc|GOvyF+iK(A-j!r1ot!0T2mdlziM{46Ghg8k=#H+V zM?tLvNCnoo3Y&aHb%nm~4lL&e!^r!5 zY>)Yt7?F2lcmBR1+QK#-XGNr7XZ8fr!cn3lZ5^Y)vUSfD^AwDN*h^Lw&)lPx++47# zd)SAA*b{C}iSS;`84M~$v>AMrgP7FJ8+gu~LAukhS6*EOJ`b`OdG>3c0~t!sZmv>H zn*HLA@+(*ivq2}#QbRtnCS6sZB|bGHY13EaXpqYpyv1DpS76m1eTdT|r_t-78YQ1T z#<62u5HD*r_L~oQCI!E8@(t$Ve*GNp63pmTN&3$4QJrKBuD-fJIu~wfYrcy;aeoU( z{gpDyo!duDy%mVwzd3}ObITpQ?&R3*fD>2bk}TRUp!6E5gQ6*el=X_*#+Q5I8?Z>{ zRy|dAN-mZA&0pz!j#b}5FeyBGiKSg%o7_9|!S#V|#ttsxpDyDUbdaS$838t Date: Mon, 12 Nov 2018 19:54:14 +0100 Subject: [PATCH 2/6] Exercise 01 - call function from dynamic library --- exercise/01/app/app.cpp | Bin 980 -> 1524 bytes exercise/01/app/app.vcxproj | 44 ++++++++++++++++-------------- exercise/01/e01.sln | 53 ++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/exercise/01/app/app.cpp b/exercise/01/app/app.cpp index 3db4891dfc2d8a4a578016fde853838473965fd9..28ff6630d32b47bb22f225abb3083d500654aac3 100644 GIT binary patch delta 458 zcmZXQ%}T>i5QR_TLSm`U5VA3`{@}uuxDcsYtX0&7x+!Uzh!B5>Q79sP2FZ&EzKR={ z`U?60em9MjAj8d_oO|ZXnR%c6X}o?}`?*HCQ>-B;k;{Fn2Mv_+@5)!7h|1Rp%+;a} zbgm;E>rmSYU|i`&IoZbBht;&kjzR=-WQ zh=sa_6VW)WaaSrmk7l$(bCqzlr;d6$L1Rn3F|OKbYEBNtW+J~T3o7)fx}Dl2Zpk%9 z{Td#C?6QlTnKMR+Xfh-+uzTW9eF>hYORX7dUyn?YvWFPZc%2xUT1r4GtZ2=w7Z>)t bl@u@b!m@+$ol-vjx2wrMr+UxDr~Um4z3EGV delta 16 YcmeyueT99)BgV~UOe~C(*;wBJ06Am@>Hq)$ diff --git a/exercise/01/app/app.vcxproj b/exercise/01/app/app.vcxproj index f959f04..f4cdc86 100644 --- a/exercise/01/app/app.vcxproj +++ b/exercise/01/app/app.vcxproj @@ -72,27 +72,27 @@ true - $(Platform)\$(Configuration) - $(Platform)\$(Configuration) + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration) - $(Platform)\$(Configuration) + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ false - $(Platform)\$(Configuration) - $(Platform)\$(Configuration) + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ false - $(Platform)\$(Configuration) - $(Platform)\$(Configuration) + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ - Use + Create Level3 Disabled true @@ -107,13 +107,13 @@ ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" -copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)\" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)\" - Use + Create Level3 Disabled true @@ -128,13 +128,13 @@ copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(P ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" -copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)\" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)\" - Use + Create Level3 MaxSpeed true @@ -153,13 +153,13 @@ copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(P ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" -copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)\" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)\" - Use + Create Level3 MaxSpeed true @@ -178,12 +178,14 @@ copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(P ..\lib\$(Platform)\$(Configuration)\;..\dll2\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)" -copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)" + copy "..\dll1\$(Platform)\$(Configuration)\dynamic_library.dll" "$(Platform)\$(Configuration)\" +copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(Platform)\$(Configuration)\" - + + Use + diff --git a/exercise/01/e01.sln b/exercise/01/e01.sln index b970a30..fea5e2c 100644 --- a/exercise/01/e01.sln +++ b/exercise/01/e01.sln @@ -10,6 +10,11 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_library_with_implib", "dll2\dynamic_library_with_implib.vcxproj", "{4EA09877-C87B-489E-9F80-A921D8E66E46}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "app", "app\app.vcxproj", "{E9C4227A-E42C-44DB-B52B-A29CC9E11111}" + ProjectSection(ProjectDependencies) = postProject + {92DBD108-3D52-419D-BC33-217327A4AD9D} = {92DBD108-3D52-419D-BC33-217327A4AD9D} + {990D865F-0DF2-40ED-8622-8DD0DB4A2128} = {990D865F-0DF2-40ED-8622-8DD0DB4A2128} + {4EA09877-C87B-489E-9F80-A921D8E66E46} = {4EA09877-C87B-489E-9F80-A921D8E66E46} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,36 +26,36 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x64.ActiveCfg = Debug|x64 {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x64.Build.0 = Debug|x64 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x86.ActiveCfg = Debug|Win32 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x86.Build.0 = Debug|Win32 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x64.ActiveCfg = Release|x64 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x64.Build.0 = Release|x64 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.ActiveCfg = Release|Win32 - {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.Build.0 = Release|Win32 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x86.ActiveCfg = Debug|x64 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Debug|x86.Build.0 = Debug|x64 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x64.ActiveCfg = Debug|x64 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x64.Build.0 = Debug|x64 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.ActiveCfg = Debug|x64 + {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.Build.0 = Debug|x64 {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x64.ActiveCfg = Debug|x64 {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x64.Build.0 = Debug|x64 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x86.ActiveCfg = Debug|Win32 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x86.Build.0 = Debug|Win32 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x64.ActiveCfg = Release|x64 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x64.Build.0 = Release|x64 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x86.ActiveCfg = Release|Win32 - {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x86.Build.0 = Release|Win32 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x86.ActiveCfg = Debug|x64 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x86.Build.0 = Debug|x64 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x64.ActiveCfg = Debug|x64 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x64.Build.0 = Debug|x64 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x86.ActiveCfg = Debug|x64 + {92DBD108-3D52-419D-BC33-217327A4AD9D}.Release|x86.Build.0 = Debug|x64 {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x64.ActiveCfg = Debug|x64 {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x64.Build.0 = Debug|x64 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x86.ActiveCfg = Debug|Win32 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x86.Build.0 = Debug|Win32 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x64.ActiveCfg = Release|x64 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x64.Build.0 = Release|x64 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.ActiveCfg = Release|Win32 - {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.Build.0 = Release|Win32 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x86.ActiveCfg = Debug|x64 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Debug|x86.Build.0 = Debug|x64 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x64.ActiveCfg = Debug|x64 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x64.Build.0 = Debug|x64 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.ActiveCfg = Debug|x64 + {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.Build.0 = Debug|x64 {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x64.ActiveCfg = Debug|x64 {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x64.Build.0 = Debug|x64 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x86.ActiveCfg = Debug|Win32 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x86.Build.0 = Debug|Win32 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x64.ActiveCfg = Release|x64 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x64.Build.0 = Release|x64 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x86.ActiveCfg = Release|Win32 - {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x86.Build.0 = Release|Win32 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x86.ActiveCfg = Debug|x64 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Debug|x86.Build.0 = Debug|x64 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x64.ActiveCfg = Debug|x64 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x64.Build.0 = Debug|x64 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x86.ActiveCfg = Debug|x64 + {E9C4227A-E42C-44DB-B52B-A29CC9E11111}.Release|x86.Build.0 = Debug|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From c5ee92a6c6a13a897ab4be694c6b73d59edfdd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20Kr=C4=8Dek?= Date: Mon, 12 Nov 2018 23:51:25 +0100 Subject: [PATCH 3/6] Exercise 02 - uncomment function calls in unit tests - implement functions according to the unit tests --- exercise/02/code.cpp | 16 ++++++++++++++++ exercise/02/code.h | 5 +++++ exercise/02/test1.cpp | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/exercise/02/code.cpp b/exercise/02/code.cpp index 85e778c..25924c8 100644 --- a/exercise/02/code.cpp +++ b/exercise/02/code.cpp @@ -1,2 +1,18 @@ #include "stdafx.h" #include "code.h" + +void f1(int& a, int& b) +{ + a = a + b; + b = a - b; + a = a - b; +} + +void f2(int* begin, int* end) +{ + while (begin != end) + { + (*begin) += 1; + begin++; + } +} \ No newline at end of file diff --git a/exercise/02/code.h b/exercise/02/code.h index e69de29..716db83 100644 --- a/exercise/02/code.h +++ b/exercise/02/code.h @@ -0,0 +1,5 @@ + + +void f1(int& a, int& b); + +void f2(int* begin, int* end); \ No newline at end of file diff --git a/exercise/02/test1.cpp b/exercise/02/test1.cpp index 33dfab7..29b52ae 100644 --- a/exercise/02/test1.cpp +++ b/exercise/02/test1.cpp @@ -14,14 +14,14 @@ namespace simple_test TEST_METHOD(f1_changes_values) { int a=1, b=2; - //f1(a, b); + f1(a, b); Assert::AreEqual(2, a); Assert::AreEqual(1, b); } TEST_METHOD(f2_increases_all_values_by_one) { int arr[] = { 1, 2, 3 }; - //f2(arr, arr+3); + f2(arr, arr+3); Assert::AreEqual(2, arr[0]); Assert::AreEqual(3, arr[1]); Assert::AreEqual(4, arr[2]); @@ -29,7 +29,7 @@ namespace simple_test TEST_METHOD(f2_works_for_different_number_of_values) { int arr[] = { 2, 4, 6, 8, 10 }; - //f2(arr, arr+5); + f2(arr, arr+5); Assert::AreEqual(3, arr[0]); Assert::AreEqual(5, arr[1]); Assert::AreEqual(7, arr[2]); From f87806f795ea3ea3586f7d25b65d00bb7997ff08 Mon Sep 17 00:00:00 2001 From: Marina Krcek Date: Tue, 13 Nov 2018 11:30:13 +0100 Subject: [PATCH 4/6] Exercise 02 - add unit tests - for loop instead of while loop (shorter code) --- exercise/02/code.cpp | 7 ++----- exercise/02/test1.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/exercise/02/code.cpp b/exercise/02/code.cpp index 25924c8..aa3ad5c 100644 --- a/exercise/02/code.cpp +++ b/exercise/02/code.cpp @@ -10,9 +10,6 @@ void f1(int& a, int& b) void f2(int* begin, int* end) { - while (begin != end) - { - (*begin) += 1; - begin++; - } + for(; begin < end; ++begin) + ++(*begin); } \ No newline at end of file diff --git a/exercise/02/test1.cpp b/exercise/02/test1.cpp index 29b52ae..b8ca411 100644 --- a/exercise/02/test1.cpp +++ b/exercise/02/test1.cpp @@ -36,5 +36,34 @@ namespace simple_test Assert::AreEqual(9, arr[3]); Assert::AreEqual(11, arr[4]); } + + TEST_METHOD(f2_custom_interval) + { + int arr[] = { 2, 4, 6, 8, 10 }; + f2(arr + 1, arr + 4); + Assert::AreEqual(2, arr[0]); + Assert::AreEqual(5, arr[1]); + Assert::AreEqual(7, arr[2]); + Assert::AreEqual(9, arr[3]); + Assert::AreEqual(10, arr[4]); + } + + TEST_METHOD(f2_wrong_size_too_small) + { + int arr[] = { 2, 4, 6 }; // OK + f2(arr, arr + 2); + Assert::AreEqual(3, arr[0]); + Assert::AreEqual(5, arr[1]); + Assert::AreEqual(6, arr[2]); + } + + TEST_METHOD(f2_end_to_begin) + { + int arr[] = { 2, 4, 6 }; + f2(arr + 2, arr); + Assert::AreEqual(2, arr[0]); + Assert::AreEqual(4, arr[1]); + Assert::AreEqual(6, arr[2]); + } }; } From b4e2a66cf6540000c06626884e28df6e785eb9ea Mon Sep 17 00:00:00 2001 From: Marina Krcek Date: Tue, 13 Nov 2018 11:45:50 +0100 Subject: [PATCH 5/6] Exercise 02 - use standard library --- exercise/02/code.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercise/02/code.cpp b/exercise/02/code.cpp index aa3ad5c..1d59eba 100644 --- a/exercise/02/code.cpp +++ b/exercise/02/code.cpp @@ -1,15 +1,14 @@ #include "stdafx.h" #include "code.h" +#include void f1(int& a, int& b) { - a = a + b; - b = a - b; - a = a - b; + std::swap(a, b); } void f2(int* begin, int* end) { - for(; begin < end; ++begin) - ++(*begin); + if (begin > end) return; + std::transform(begin, end, begin, [](int n) {return n + 1; }); } \ No newline at end of file From f2ee123cfac6f865f26ee08f685b82f34c2a3d25 Mon Sep 17 00:00:00 2001 From: Marina Krcek Date: Tue, 13 Nov 2018 15:35:10 +0100 Subject: [PATCH 6/6] Exercise 01 - only pch.cpp has 'Create' for PrecompiledHeader --- exercise/01/app/app.vcxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercise/01/app/app.vcxproj b/exercise/01/app/app.vcxproj index f4cdc86..14774c9 100644 --- a/exercise/01/app/app.vcxproj +++ b/exercise/01/app/app.vcxproj @@ -185,6 +185,9 @@ copy "..\dll2\$(Platform)\$(Configuration)\dynamic_library_with_implib.dll" "$(P Use + Use + Use + Use