File: tests-replace.cpp

package info (click to toggle)
xmlcopyeditor 1.3.1.0-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 24,528 kB
  • sloc: xml: 140,240; cpp: 29,372; sh: 4,925; makefile: 299; sed: 16
file content (19 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "catch.hpp"
#include <string>
#include "../src/replace.h"

TEST_CASE( "replace works as specified", "[replace]" ) {
  std::string orig = "when shall we three meet again";
  std::string find = "THREE";
  std::string replace = "four";

  // case insensitive
  std::string buf = orig;
  REQUIRE( Replace::run(buf, find, replace, false) == 1 );
  REQUIRE( buf == "when shall we four meet again" );

  // case sensitive
  buf = orig;
  REQUIRE( Replace::run(buf, find, replace, true) == 0 );
  REQUIRE( buf == "when shall we three meet again" );
}