stof 0.3.5

Stof is a unified data interface and interchange format for creating, sharing, and manipulating data. Stof removes the fragile and cumbersome parts of combining and using data in applications.
Documentation
//
// Copyright 2024 Formata, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


#[test]
fn length() {
    assertEq('hello'.len(), 5);
}

#[test]
fn indexing() {
    let str = 'hello';
    assertEq(str.at(4), 'o');
    assertEq(str[1], 'e');
    assertEq(str.first(), 'h');
    assertEq(str.last(), 'o');
}

#[test]
fn starts_with() {
    let str = 'hello';
    assert(str.startsWith('hel'));
    assert(!str.startsWith('ho'));
}

#[test]
fn ends_with() {
    let str = 'hello';
    assert(str.endsWith('llo'));
    assert(!str.endsWith('t'));
}

#[test]
fn push() {
    let str = 'hello';
    str.push(', world');
    assertEq(str, 'hello, world');
}

#[test]
fn contains() {
    let str = 'hello';
    assert(str.contains('hell'));
    assert(!str.contains('world'));
}

#[test]
fn index_of() {
    let str = 'hello';
    assertEq(str.indexOf('llo'), 2);
    assertEq(str.indexOf('world'), -1);
}

#[test]
fn replace_all() {
    let str = 'hello';
    assertEq(str.replace('l', 'DUDE'), 'heDUDEDUDEo');
}

#[test]
fn split() {
    let str = 'hello';
    assertEq(str.split('ll'), ['he', 'o']);
}

#[test]
fn substring() {
    let str = 'hello';
    assertEq(str.substring(2), 'llo');
    assertEq(str.substring(2, 4), 'll');
}

#[test]
fn to_upper() {
    let str = 'hello';
    assertEq(str.toUpper(), 'HELLO');
}

#[test]
fn to_lower() {
    let upper = 'HI THERE';
    assertEq(upper.toLower(), 'hi there');
}

#[test]
fn trim() {
    let to_trim = '    trim    ';
    assertEq(to_trim.trim(), 'trim');
    assertEq(to_trim.trimStart(), 'trim    ');
    assertEq(to_trim.trimEnd(), '    trim');
}