Internal Test: Tests edge cases for patterns that are not found or are at the start of the string.
ID: 1271
See: Before
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("A B C")) {
// Case 1: Pattern is at the start. Should return an empty string.
Console.Write("Before 'A': '");
Console.Write(s.Before("A"));
Console.WriteLine("'");
// Case 2: Pattern does not exist. Should return an empty string.
Console.Write("Before 'D': '");
Console.Write(s.Before("D"));
Console.WriteLine("'");
// Case 3: Get text before the last word.
Console.Write("Before 'C': '");
Console.Write(s.Before("C"));
Console.WriteLine("'");
}
Before 'A': ''
Before 'D': ''
Before 'C': 'A B ' using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("A B C")) { // Case 1: Pattern is at the start. Should return an empty string. Console.Write("Before 'A': '"); Console.Write(s.Before("A")); Console.WriteLine("'"); // Case 2: Pattern does not exist. Should return an empty string. Console.Write("Before 'D': '"); Console.Write(s.Before("D")); Console.WriteLine("'"); // Case 3: Get text before the last word. Console.Write("Before 'C': '"); Console.Write(s.Before("C")); Console.WriteLine("'"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("A B C");
s.Owned(); // Causes s to be released when it goes out of scope
// Case 1: Pattern is at the start. Should return an empty string.
cout << "Before 'A': '";
cout << s.Before("A");
cout << "'" << endl;
// Case 2: Pattern does not exist. Should return an empty string.
cout << "Before 'D': '";
cout << s.Before("D");
cout << "'" << endl;
// Case 3: Get text before the last word.
cout << "Before 'C': '";
cout << s.Before("C");
cout << "'" << endl;
}
}
Before 'A': ''
Before 'D': ''
Before 'C': 'A B ' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("A B C"); s.Owned(); // Causes s to be released when it goes out of scope // Case 1: Pattern is at the start. Should return an empty string. cout << "Before 'A': '"; cout << s.Before("A"); cout << "'" << endl; // Case 2: Pattern does not exist. Should return an empty string. cout << "Before 'D': '"; cout << s.Before("D"); cout << "'" << endl; // Case 3: Get text before the last word. cout << "Before 'C': '"; cout << s.Before("C"); cout << "'" << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("A B C")
'// Case 1: Pattern is at the start. Should return an empty string.
Console.Write("Before 'A': '")
Console.Write(s.Before("A"))
Console.WriteLine("'")
'// Case 2: Pattern does not exist. Should return an empty string.
Console.Write("Before 'D': '")
Console.Write(s.Before("D"))
Console.WriteLine("'")
'// Case 3: Get text before the last word.
Console.Write("Before 'C': '")
Console.Write(s.Before("C"))
Console.WriteLine("'")
End Using
End Sub
End Module
Before 'A': ''
Before 'D': ''
Before 'C': 'A B ' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("A B C") '// Case 1: Pattern is at the start. Should return an empty string. Console.Write("Before 'A': '") Console.Write(s.Before("A")) Console.WriteLine("'") '// Case 2: Pattern does not exist. Should return an empty string. Console.Write("Before 'D': '") Console.Write(s.Before("D")) Console.WriteLine("'") '// Case 3: Get text before the last word. Console.Write("Before 'C': '") Console.Write(s.Before("C")) Console.WriteLine("'") End Using End Sub End Module