// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader test_split_v_str_v_sep_u_max (output vector res=0, 
           output vector calres = 0)
{
    string var_str = format("%f",v);
    string var_sep = format("%d", int(u)*2); //Varying sep
    int uniform_maxsplit = 2;//Uniform maxsplit
        
    //Initialize result output array
    string results[4] = {var_str,var_str,var_str,var_str}; 
    string results1[4] = {var_str,var_str,var_str,var_str};
    
    int accum1 = 0;
    int sc1 = 0;
    sc1 = split(format("%f %d %f  %f", 2*u, int(u)*2, 6*(u-v), 8*(u-v)),results, var_sep, uniform_maxsplit); //varying string amd varying separator
    
    for (int i = 0 ; i<sc1; ++i) {
        accum1 += stoi(results[i]);
    }
    res = vector (accum1/40.0, u, (float) sc1*u);
    
    
    int accum2 = 0;
    int sc2 = 0;
    
    if(int(P[0]*64)%2) {
         sc2 = split(format("%f %d %f %f", 3*v, int(u)*2, 9*u,12*u),results1, var_sep, uniform_maxsplit);//varying string and varying sep
    }
    
    for (int i = 0; i<sc2; ++i) {
        accum2 += stoi(results1[i]);
    }
    
    calres = vector(((float)accum2)+4.0/(13.0 + u*13), u+v, ((float)accum1)+4.0/(9.0 + v*9.0));
}
