From 2e649d0798c9b04069a918bea0ff823f007473d8 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:40:39 +0300 Subject: [PATCH 1/7] begin --- .travis.yml | 31 +++++ CMakeLists.txt | 23 +++- LICENSE.txt | 22 ++++ appveyor.yml | 20 ++++ include/MyString.h | 55 +++++++++ src/string.cpp | 268 ++++++++++++++++++++++++++++++++++++++++++ tests/test_string.cpp | 249 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 663 insertions(+), 5 deletions(-) create mode 100644 .travis.yml create mode 100644 LICENSE.txt create mode 100644 appveyor.yml create mode 100644 include/MyString.h create mode 100644 src/string.cpp create mode 100644 tests/test_string.cpp diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d65ed7f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +sudo: false + +language: cpp + +compiler: + - clang + - gcc + +before_install: + - pip install --user cpp-coveralls + +install: + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi + - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi + - mkdir build + - cd build + - cmake .. + - make + +script: + - ctest -V + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + packages: + - gcc-4.9 + - g++-4.9 + - clang-3.7 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cc23c9..7feb669 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,20 @@ -cmake_minimum_required(VERSION 3.3) -project(super_hot_strings) +cmake_minimum_required(VERSION 2.8) +project(CppLab2) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +if (MSVC) + add_definitions(/W4) +else() + add_definitions(-Wall) + add_definitions(-std=c++11) +endif() -set(SOURCE_FILES main.cpp) -add_executable(super_hot_strings ${SOURCE_FILES}) \ No newline at end of file +include_directories(Catch/include) +include_directories(include) + +enable_testing() + +set(SOURCES src/string.cpp) + +add_executable(test_string tests/test_string.cpp ${SOURCES}) + +add_test(NAME ${PROJECT_NAME} COMMAND test_string) \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5bf4c60 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 sdukshis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..7ddbd3a --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,20 @@ +version: 1.0.{build} + +clone_folder: c:\dev\complex + +build: + +install: + - git submodule -q update --init --recursive + +build_script: + - cd c:\dev\complex + - md build + - cd build + - cmake .. + - cmake --build . --config debug + +after_build: + +test_script: + - cmd: ctest -C Debug -VV diff --git a/include/MyString.h b/include/MyString.h new file mode 100644 index 0000000..9109609 --- /dev/null +++ b/include/MyString.h @@ -0,0 +1,55 @@ +#ifndef CPP_STRING_H +#define CPP_STRING_H +//one definition rule + +class String { +private: + std::size_t length; //length of actual string, w/o EOL symvol + char * string; +public: + static char position; + String(); + String(const char *str); + String(const char *str, unsigned count); + String(char ch, unsigned count); + String(const String &other); + String(String &&other); + ~String(); + String & operator=(const String &other); + String & operator=(String &&other); + + String & operator+=(const String &suffix); + String & operator+=(const char *suffix); + String & operator+=(char suffix); + void swap(String &other); + char & operator[](size_t pos); + const char operator[](size_t pos) const; +/** +throws an exception if pos >= size() +*/ + char & at(size_t pos); + +/** +throws an exception if pos >= size() +*/ + const char at(size_t pos) const; +/** +/return pointer to '\0' terminated C-style string +*/ + const char * data() const; + size_t size() const; + friend bool operator==(const String &lhs, const String &rhs); + friend bool operator<(const String &lhs, const String &rhs); +}; +String operator+(const String &lhs, const String &rhs); +String operator+(const String &lhs, const char *rhs); +String operator+(const char *lhs, const String &rhs); +bool operator!=(const String &lhs, const String &rhs); +bool operator<=(const String &lhs, const String &rhs); +bool operator>(const String &lhs, const String &rhs); +bool operator>=(const String &lhs, const String &rhs); +#endif + + + + diff --git a/src/string.cpp b/src/string.cpp new file mode 100644 index 0000000..841c7e3 --- /dev/null +++ b/src/string.cpp @@ -0,0 +1,268 @@ +#include +#include +#include "MyString.h" + + +String::String() { + length = 0; + string = new char[1]; + string[0] = '\0'; +} + +String::String(const char *str) { + while (*(str++) != '\0') { + length++; + } + char *strCopy = new char[length + 1]; + for (std::size_t i = 0; i < length; i++) { + strCopy[i] = str[i]; + } + +} + +//cut from beginning +String::String(const char *str, unsigned count) { + string = new char[count + 1]; + length = count; + for (std::size_t i = 0; i <= length; i++) { + string[i] = str[i]; + } +} + +//repeat symbol count times +String::String(char ch, unsigned count) { + length = count + 1; + string = new char[length]; + char *temp = string; + + for (std::size_t i = 0; i < length; ++i) { + *(temp++) = ch; + } + *(temp) = '\0'; + +} + +//copy constructor +String::String(const String &other) { + string = new char[other.length + 1]; + length = other.length; + for (size_t i = 0; i < length; ++i) { + string[i] = other.string[i]; + } +} + + +String::String(String &&other) { + string = other.string; + length = other.length; + other.string[0] = '\0'; + other.length = 0; +} + + +String::~String() { + if (string[0] != '\0') { + delete[] string; + } +} + +//optize +String &String::operator=(const String &other) { + delete[] string; + string = new char[other.length + 1]; + length = other.length; + for (size_t i = 0; i < length; i++) { + string[i] = other.string[i]; + } + string[length] = '\0'; + return *this; +} + +String &String::operator=(String &&other) { + delete[] string; + string = other.string; + length = other.length; + other.string[0] = '\0'; + other.length = 0; + return *this; + +} + +String &String::operator+=(const String &suffix) { + char *concat = new char[length + suffix.length + 1]; + for (size_t i = 0; i < length; ++i) { + concat[i] = string[i]; + } + for (size_t j = length; j < length + suffix.length; ++j) { + concat[j] = suffix.string[j]; + } + concat[length + suffix.length] = '\0'; + delete[] string; + string = concat; + length += suffix.length; + + return *this; +} + +String &String::operator+=(const char *suffix) { + size_t suffixLength = 0; + const char * temp = suffix; + while (*(temp++) != '\0') { + suffixLength++; + } + + char *concat = new char[length + suffixLength + 1]; + for (size_t i = 0; i < length; ++i) { + concat[i] = string[i]; + } + for (size_t j = length; j < length + suffixLength; ++j) { + concat[j] = suffix[j]; + } + concat[length+suffixLength]='\0'; + delete[] string; + string = concat; + length += suffixLength; + return *this; +} + +String &String::operator+=(char suffix) { + char *concat = new char[length + 2]; + for (size_t i = 0; i < length; ++i) { + concat[i] = string[i]; + } + concat[length] = suffix; + concat[length + 1] = '\0'; + delete [] string; + string = concat; + length++; + return *this; +} + +void String::swap(String &other) { + char *tmp; + size_t tmpLength; + tmp = string; + tmpLength = length; + string = other.string; + length = other.length; + other.string = tmp; + other.length = tmpLength; +} + +char &String::operator[](size_t pos) { + return string[pos]; +} + +const char String::operator[](size_t pos) const { + return string[pos]; +} + +char &String::at(size_t pos) { + if (pos >= length) { + throw std::out_of_range(""); + } + return string[pos]; +} + +//this is the same +const char String::at(size_t pos) const { + if (pos >= length ) { + throw std::out_of_range(""); + } + return string[pos]; +} + +const char *String::data() const { + return string; +} + +size_t String::size() const { + return length; +} + +bool operator==(const String &lhs, const String &rhs) { + if (lhs.length == rhs.length) { + for (size_t i = 0; i < lhs.length; ++i) { + if (lhs.string[i] != rhs.string[i]) { + return false; + } + } + return true; + } + return false; +} + +bool operator<(const String &lhs, const String &rhs) { + size_t size; + size = lhs.length <= rhs.length ? lhs.length : rhs.length; + for (size_t i = 0; i < size; ++i) { + if (lhs.string[i] < rhs.string[i]) { + return true; + } else if (lhs.string[i] > rhs.string[i]) { + return false; + } + } + return false; +} + + +String operator+(const String &lhs, const String &rhs) { + return String(lhs) += rhs; +} + +String operator+(const String &lhs, const char *rhs) { + return String(lhs) += rhs; +} + +String operator+(const char *lhs, const String &rhs) { + return String(rhs) += lhs; +} + +bool operator!=(const String &lhs, const String &rhs) { + return !(lhs == rhs); +} + +bool operator<=(const String &lhs, const String &rhs) { + return (lhs == rhs) || (lhs < rhs); +} + +bool operator>(const String &lhs, const String &rhs) { + return !(lhs <= rhs); +} + +bool operator>=(const String &lhs, const String &rhs) { + return !(lhs < rhs); +} + + +std::ostream &operator<<(std::ostream &stream, const String &A) { + return stream << A.data(); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_string.cpp b/tests/test_string.cpp new file mode 100644 index 0000000..c923c71 --- /dev/null +++ b/tests/test_string.cpp @@ -0,0 +1,249 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "MyString.h" + + + +TEST_CASE("TEST 1") { + String s; + REQUIRE(*(s.data()) == '\0'); + REQUIRE(s.size() == 0); +} + +TEST_CASE("TEST 2") { + char B[] = "Test2"; + String A(B); + const char *pt = A.data(); + REQUIRE(A.size() == 5); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(B[i] == *(pt++)); + } +} + +TEST_CASE("TEST 3") { + char * B = "Test3"; + String A(B, 5); + const char *pt = A.data(); + REQUIRE(A.size() == 5); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(B[i] == *(pt++)); + } +} + +TEST_CASE("Test 4") { + char B = 'q'; + String A(B, 10); + const char *pt = A.data(); + REQUIRE(A.size() == 10); + for (unsigned i = 0; i < A.size(); ++i) { + REQUIRE(B == *(pt++)); + } + REQUIRE('\0' == *pt); +} + +TEST_CASE("Test5") { + String B("Test5"); + String A(B); + REQUIRE(A.size() == B.size()); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(B[i] == A[i]); + } +} + +TEST_CASE("Test6") { + String B("Test6"); + String C(B); + String A(std::move(B)); + REQUIRE(A.size() == C.size()); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(C[i] == A[i]); + } + REQUIRE(B.size() == 0); + REQUIRE(*(B.data()) == '\0'); +} + +TEST_CASE ("Test_assigment1") { + String A("Test_assigment1"); + String B, C; + C = B = A; + REQUIRE(A.size() == C.size()); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(C[i] == A[i]); + } +} + +TEST_CASE ("Test_assigment2") { + String B("Test_assigment2"); + String C = B; + String A = std::move(B); + REQUIRE(A.size() == C.size()); + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(C[i] == A[i]); + } + REQUIRE(B.size() == 0); + REQUIRE(*(B.data()) == '\0'); +} + +TEST_CASE ("Test_plus_assigment_1") { + char *res = "plus_assigment"; + String A("plus_"); + size_t Asize = A.size(); + String B("assigment"); + size_t Bsize = B.size(); + A += B; + REQUIRE(A.size() == (Asize + Bsize)); + for (size_t i = 0; i <= A.size(); ++i) { + REQUIRE(res[i] == A[i]); + } +} + +TEST_CASE ("Test_plus_assigment_2") { + char *res = "plus_assigment"; + String C("plus_"); + size_t Csize = C.size(); + char A[] = "assigment"; + size_t Asize = 9; + String B("plus_"); + size_t Bsize = B.size(); + C += A; + B += "assigment"; + REQUIRE((Asize + Csize) == C.size()); + REQUIRE(B.size() == (Asize + Bsize)); + REQUIRE(B.size() == C.size()); + for (size_t i = 0; i <= C.size(); ++i) { + REQUIRE(res[i] == C[i]); + REQUIRE(res[i] == B[i]); + } +} + +TEST_CASE ("Test_plus_assigment_3") { + char *res = "plus_"; + String C("plus"); + size_t Csize = C.size(); + char A = '_'; + size_t Asize = 1; + String B("plus"); + size_t Bsize = B.size(); + C += A; + B += '_'; + REQUIRE((Asize + Csize) == C.size()); + REQUIRE(B.size() == (Asize + Bsize)); + REQUIRE(B.size() == C.size()); + for (size_t i = 0; i <= B.size(); ++i) { + REQUIRE(res[i] == C[i]); + REQUIRE(res[i] == B[i]); + } +} + +TEST_CASE ("Test_index") { + String A("Test"); + A[1] = 'a'; + char *res = "Tast"; + for (unsigned i = 0; i <= A.size(); ++i) { + REQUIRE(res[i] == A[i]); + } +} + +TEST_CASE ("Test_swap") { + char *res1 = "hgf"; + char *res2 = "lkjhgf"; + String A(res1); + String B(res2); + size_t Asize = A.size(); + size_t Bsize = B.size(); + A.swap(B); + REQUIRE(Bsize == A.size()); + REQUIRE(Asize == B.size()); + for (size_t i = 0; i <= A.size(); ++i) { + REQUIRE(res2[i] == A[i]); + } + for (size_t i = 0; i <= B.size(); ++i) { + REQUIRE(res1[i] == B[i]); + } +} + +TEST_CASE ("Test_at") { + const String A("Test_at"); + REQUIRE(A.at(3) == 't'); + REQUIRE_THROWS(A.at(10)); +} + +TEST_CASE ("Test_equality") { + String A("Test"); + String B(A); + REQUIRE(A.size() == B.size()); + for (size_t i = 0; i < A.size(); ++i) { + REQUIRE(A[i] == B[i]); + } +} + +TEST_CASE ("Test_less") { + String A("Test"); + String B(A); + REQUIRE(A < B); + B += "er"; + REQUIRE_FALSE(A < B); +} + +TEST_CASE ("Test_plus_1") { + String A("Test_"); + String B("plus_1"); + String C; + String res("Test_plus_1"); + C = A + B; + A = A + B; + REQUIRE(C == res); + REQUIRE(A == res); +} + +TEST_CASE ("Test_plus_2") { + String A("Test_"); + char * B = "plus_1"; + String C; + String res("Test_plus_1"); + C = A + B; + A = A + B; + REQUIRE(C == res); + REQUIRE(A == res); +} + +TEST_CASE ("Test_plus_3") { + String A("Test_"); + char * B = "plus_1"; + String C; + String res("Test_plus_1"); + C = B + A; + A = B + A; + REQUIRE(C == res); + REQUIRE(A == res); +} + +TEST_CASE ("Test_not_equality") { + String A("kjh"); + String B("hgh"); + REQUIRE(!(A == B)); +} + +TEST_CASE ("Test_less_equality") { + String A("less"); + String B("equality"); + String C("less"); + REQUIRE(((B <= A) && (A <= C))); + +} + +TEST_CASE ("Test_more") { + String A("more"); + String B("aaaaa"); + REQUIRE(A > B); + +} + +TEST_CASE ("Test_more_equality") { + String A("more"); + String B("more"); + String C("equality"); + REQUIRE(((B >= A) && (A >= C))); + +} From 25195c3186e3cac559b9717a2d13f2d77b0ecc22 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:40:39 +0300 Subject: [PATCH 2/7] Create README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4570e4 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Super Hot Strings for U and ME From 8b5ab44251ae076e2de9f22dde91c1752ac16043 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:46:30 +0300 Subject: [PATCH 3/7] almost done --- include/MyString.h | 2 +- src/string.cpp | 40 +++++++++++++++++++++++++++------------- tests/test_string.cpp | 11 +++++++---- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/include/MyString.h b/include/MyString.h index 9109609..d8e2cd8 100644 --- a/include/MyString.h +++ b/include/MyString.h @@ -4,7 +4,7 @@ class String { private: - std::size_t length; //length of actual string, w/o EOL symvol + size_t length; //length of actual string, w/o EOL symvol char * string; public: static char position; diff --git a/src/string.cpp b/src/string.cpp index 841c7e3..4d265e5 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -10,7 +10,9 @@ String::String() { } String::String(const char *str) { - while (*(str++) != '\0') { + length = 0; + const char *temp = str; + while (*(temp++) != '\0') { length++; } char *strCopy = new char[length + 1]; @@ -18,6 +20,8 @@ String::String(const char *str) { strCopy[i] = str[i]; } + string = strCopy; + string[length] = '\0'; } //cut from beginning @@ -31,8 +35,8 @@ String::String(const char *str, unsigned count) { //repeat symbol count times String::String(char ch, unsigned count) { - length = count + 1; - string = new char[length]; + length = count; + string = new char[length + 1]; char *temp = string; for (std::size_t i = 0; i < length; ++i) { @@ -46,7 +50,7 @@ String::String(char ch, unsigned count) { String::String(const String &other) { string = new char[other.length + 1]; length = other.length; - for (size_t i = 0; i < length; ++i) { + for (size_t i = 0; i <= length; ++i) { string[i] = other.string[i]; } } @@ -55,7 +59,9 @@ String::String(const String &other) { String::String(String &&other) { string = other.string; length = other.length; - other.string[0] = '\0'; + //other.string[0] = '\0'; //no magic + char nully = '\0'; + other.string = &(nully); //magic other.length = 0; } @@ -82,7 +88,9 @@ String &String::operator=(String &&other) { delete[] string; string = other.string; length = other.length; - other.string[0] = '\0'; + + char nully = '\0'; + other.string = &(nully); //magic #2 other.length = 0; return *this; @@ -94,7 +102,7 @@ String &String::operator+=(const String &suffix) { concat[i] = string[i]; } for (size_t j = length; j < length + suffix.length; ++j) { - concat[j] = suffix.string[j]; + concat[j] = suffix.string[j - length]; } concat[length + suffix.length] = '\0'; delete[] string; @@ -106,7 +114,7 @@ String &String::operator+=(const String &suffix) { String &String::operator+=(const char *suffix) { size_t suffixLength = 0; - const char * temp = suffix; + const char *temp = suffix; while (*(temp++) != '\0') { suffixLength++; } @@ -116,9 +124,9 @@ String &String::operator+=(const char *suffix) { concat[i] = string[i]; } for (size_t j = length; j < length + suffixLength; ++j) { - concat[j] = suffix[j]; + concat[j] = suffix[j - length]; } - concat[length+suffixLength]='\0'; + concat[length + suffixLength] = '\0'; delete[] string; string = concat; length += suffixLength; @@ -132,7 +140,7 @@ String &String::operator+=(char suffix) { } concat[length] = suffix; concat[length + 1] = '\0'; - delete [] string; + delete[] string; string = concat; length++; return *this; @@ -166,7 +174,7 @@ char &String::at(size_t pos) { //this is the same const char String::at(size_t pos) const { - if (pos >= length ) { + if (pos >= length) { throw std::out_of_range(""); } return string[pos]; @@ -202,12 +210,18 @@ bool operator<(const String &lhs, const String &rhs) { return false; } } + if (rhs.length > lhs.length) { + return true; + } return false; } String operator+(const String &lhs, const String &rhs) { - return String(lhs) += rhs; + String tmp(lhs); + tmp += rhs; + return tmp; +// return (String(lhs) += rhs); } String operator+(const String &lhs, const char *rhs) { diff --git a/tests/test_string.cpp b/tests/test_string.cpp index c923c71..2a919ca 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -12,7 +12,7 @@ TEST_CASE("TEST 1") { } TEST_CASE("TEST 2") { - char B[] = "Test2"; + char B[] = "Test2"; String A(B); const char *pt = A.data(); REQUIRE(A.size() == 5); @@ -22,7 +22,7 @@ TEST_CASE("TEST 2") { } TEST_CASE("TEST 3") { - char * B = "Test3"; + char B[] = "Test3"; String A(B, 5); const char *pt = A.data(); REQUIRE(A.size() == 5); @@ -181,9 +181,11 @@ TEST_CASE ("Test_equality") { TEST_CASE ("Test_less") { String A("Test"); String B(A); - REQUIRE(A < B); - B += "er"; REQUIRE_FALSE(A < B); + B += "er"; + REQUIRE(A < B); + A+="aa"; + REQUIRE(A < B); } TEST_CASE ("Test_plus_1") { @@ -191,6 +193,7 @@ TEST_CASE ("Test_plus_1") { String B("plus_1"); String C; String res("Test_plus_1"); + C = A + B; A = A + B; REQUIRE(C == res); From afaeae8dc943778ce667ea5914da4e1ba7ab6382 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:47:29 +0300 Subject: [PATCH 4/7] almost done --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d4570e4..f30cc52 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ # Super Hot Strings for U and ME +# realisation of non-native strings \ No newline at end of file From 6fec7a007c46b4de92506db20650b7a64f2355d1 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:51:41 +0300 Subject: [PATCH 5/7] almost done --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f30cc52..7879b33 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Super Hot Strings for U and ME +----------------------------------- # realisation of non-native strings \ No newline at end of file From 2008249489fc05925940ac19445fa8cb8de693a5 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 06:57:58 +0300 Subject: [PATCH 6/7] almost almost done --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7879b33..2688db3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ -# Super Hot Strings for U and ME +# Super Hot Strings for U and ME +[![Build Status](https://travis-ci.org/Waaazzzuuup/SHS.svg)](https://travis-ci.org/Waaazzzuuup/SHS) +[![Build status](https://ci.appveyor.com/api/projects/status/o79ympra1gx16ubn?svg=true)](https://ci.appveyor.com/project/Waaazzzuuup/shs) ----------------------------------- # realisation of non-native strings \ No newline at end of file From c3dfae7392ddfd4d7ac86cae72f172ef0e6512f1 Mon Sep 17 00:00:00 2001 From: Waaazzzuuup Date: Thu, 14 Jan 2016 07:02:31 +0300 Subject: [PATCH 7/7] IT S A FINAL COUNTDOWN --- tests/test_string.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 2a919ca..89a8e0e 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -86,7 +86,7 @@ TEST_CASE ("Test_assigment2") { } TEST_CASE ("Test_plus_assigment_1") { - char *res = "plus_assigment"; + char res[] = "plus_assigment"; String A("plus_"); size_t Asize = A.size(); String B("assigment"); @@ -99,7 +99,7 @@ TEST_CASE ("Test_plus_assigment_1") { } TEST_CASE ("Test_plus_assigment_2") { - char *res = "plus_assigment"; + char res[] = "plus_assigment"; String C("plus_"); size_t Csize = C.size(); char A[] = "assigment"; @@ -118,7 +118,7 @@ TEST_CASE ("Test_plus_assigment_2") { } TEST_CASE ("Test_plus_assigment_3") { - char *res = "plus_"; + char res[] = "plus_"; String C("plus"); size_t Csize = C.size(); char A = '_'; @@ -139,15 +139,15 @@ TEST_CASE ("Test_plus_assigment_3") { TEST_CASE ("Test_index") { String A("Test"); A[1] = 'a'; - char *res = "Tast"; + char res[] = "Tast"; for (unsigned i = 0; i <= A.size(); ++i) { REQUIRE(res[i] == A[i]); } } TEST_CASE ("Test_swap") { - char *res1 = "hgf"; - char *res2 = "lkjhgf"; + char res1[] = "hgf"; + char res2[] = "lkjhgf"; String A(res1); String B(res2); size_t Asize = A.size(); @@ -202,7 +202,7 @@ TEST_CASE ("Test_plus_1") { TEST_CASE ("Test_plus_2") { String A("Test_"); - char * B = "plus_1"; + char B[] = "plus_1"; String C; String res("Test_plus_1"); C = A + B;