Internal Test: Verifies that requesting an out-of-bounds index for a token type returns an empty item.
ID: 1020
See: ByType
using uCalcSoftware;
var uc = new uCalc();
var tokens = uc.ExpressionTokens;
// There is only one Alphanumeric token, so index 1 is out of bounds.
var outOfBoundsToken = tokens.ByType(TokenType.AlphaNumeric, 1);
Console.WriteLine($"Is token empty? {outOfBoundsToken.IsEmpty()}");
Console.WriteLine($"Was token found? {! outOfBoundsToken.IsProperty(ItemIs.NotFound)}");
Is token empty? True
Was token found? False using uCalcSoftware; var uc = new uCalc(); var tokens = uc.ExpressionTokens; // There is only one Alphanumeric token, so index 1 is out of bounds. var outOfBoundsToken = tokens.ByType(TokenType.AlphaNumeric, 1); Console.WriteLine($"Is token empty? {outOfBoundsToken.IsEmpty()}"); Console.WriteLine($"Was token found? {! outOfBoundsToken.IsProperty(ItemIs.NotFound)}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto tokens = uc.ExpressionTokens();
// There is only one Alphanumeric token, so index 1 is out of bounds.
auto outOfBoundsToken = tokens.ByType(TokenType::AlphaNumeric, 1);
cout << "Is token empty? " << tf(outOfBoundsToken.IsEmpty()) << endl;
cout << "Was token found? " << tf(not outOfBoundsToken.IsProperty(ItemIs::NotFound)) << endl;
}
Is token empty? True
Was token found? False #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto tokens = uc.ExpressionTokens(); // There is only one Alphanumeric token, so index 1 is out of bounds. auto outOfBoundsToken = tokens.ByType(TokenType::AlphaNumeric, 1); cout << "Is token empty? " << tf(outOfBoundsToken.IsEmpty()) << endl; cout << "Was token found? " << tf(not outOfBoundsToken.IsProperty(ItemIs::NotFound)) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim tokens = uc.ExpressionTokens
'// There is only one Alphanumeric token, so index 1 is out of bounds.
Dim outOfBoundsToken = tokens.ByType(TokenType.AlphaNumeric, 1)
Console.WriteLine($"Is token empty? {outOfBoundsToken.IsEmpty()}")
Console.WriteLine($"Was token found? {not outOfBoundsToken.IsProperty(ItemIs.NotFound)}")
End Sub
End Module
Is token empty? True
Was token found? False Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim tokens = uc.ExpressionTokens '// There is only one Alphanumeric token, so index 1 is out of bounds. Dim outOfBoundsToken = tokens.ByType(TokenType.AlphaNumeric, 1) Console.WriteLine($"Is token empty? {outOfBoundsToken.IsEmpty()}") Console.WriteLine($"Was token found? {not outOfBoundsToken.IsProperty(ItemIs.NotFound)}") End Sub End Module