Skip to content

Strs

Description

Vector of strings

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    static Strs str_split_impl(Str *s, Zstr key, size keylen) {
        ValidateStr(s);
        ValidateStr(s);
    
        Strs sv        = (Strs)VecInit(s->allocator);
        sv.copy_deinit = (GenericCopyDeinit)str_deinit;
        Zstr prev      = s->data;
    }
    
    Strs str_split_zstr(Str *s, Zstr key) {
        return str_split_impl(s, key, ZstrLen(key));
    }
    }
    
    Strs str_split_str(Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    void ValidateStrs(const Strs *vs) {
        ValidateVec(vs);
        VecForeachPtr(vs, sp) {
        // Test StrSplit
        Str  s     = StrInitFromZstr("Hello,World,Test", &alloc);
        Strs split = StrSplit(&s, ",");
    
        bool result = (VecLen(&split) == 3);
    // Test Strs type definition
    bool test_strs_type(void) {
        WriteFmt("Testing Strs type definition\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Create a Strs object (vector of strings)
        Strs sv = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Add some strings
    
        // Create a valid Strs
        Strs sv = VecInit(&alloc);
    
        // This should not crash
    // Deadend test: Test ValidateStrs with invalid Strs (should crash/abort)
    bool test_validate_invalid_strs(void) {
        WriteFmt("Testing ValidateStrs with invalid Strs (should abort)\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Create an invalid Strs by corrupting its fields
        Strs sv = VecInit(&alloc);
    
        // Corrupt the vector to make it invalid
    /// TAGS: Str, Validate, API
    ///
    void ValidateStrs(const Strs *vs);
    
    #endif // MISRA_STD_CONTAINER_STR_TYPE_H
Last updated on