load_file("FormatFile.hoc")

objref vec, outfile
objref mat, l
strdef str
chooser_test=0

proc print_tests() {
    // Double
    a = 5 
    outfile.printdouble("a",a)
    
    // empty vector
    vec = new Vector()
    outfile.printvec("vec",vec) 
    
    // Short vector
    vec.indgen(1,10,1)
    outfile.printvec("vec",vec)
    
    //  Partial printing
    outfile.printvec("vec",vec,4,7)
    
    // Longer vector
    vec.indgen(1,25,1)
    outfile.printvec("vec",vec)
    //     printmvec(outfile,vec,"vec",4,7)
    //    oprintmvec(outfile,vec,"vec",4,22)
    
    // A vector just on the block size
    vec.indgen(1,100,1)
    outfile.printvec("vec",vec)
    outfile.printvec("vec",vec,55,72)
    
    // A vector bigger than the block size
    vec.indgen(1,101,1)
    outfile.printvec("vec",vec)
    
    // A matrix
    mat = new Matrix(6,101)
    for i = 0, 5 {
        mat.setrow(0, vec)
    }
    outfile.printmat("mat",mat)
    
    str = "blee blee blee2"
    outfile.printstr("str",str)
    
    // Printing types without specifying type
    outfile.printobj("obja",a)
    outfile.printobj("objvec",vec)
    outfile.printobj("objmat",mat)
    outfile.printobj("objstr",str)
    
    // List test
    l = new List()
    l.append(vec)
    l.append(mat)
    outfile.printlist("l", l)
}    

// Should complain about this
outfile = new FormatFile("test_FormatFile.null","skdfh")

outfile = new FormatFile("test_FormatFile")

outfile.wopen()
print_tests()
outfile.close()

outfile = new FormatFile("test_FormatFile","R")
outfile.wopen()
print_tests()
outfile.close()

outfile = new FormatFile("test_FormatFile-struct","R","r")
outfile.wopen()
print_tests()
outfile.close()

// Chooser test
if (chooser_test==1) {
    outfile = new FormatFile("","R")
    outfile.chooser("w","Hello")
    outfile.chooser()
    outfile.wopen()
    print_tests()
    outfile.close()
}

// Hoc test

outfile = new FormatFile("/tmp/test_FormatFile","hoc")
outfile.wopen()
print_tests()
outfile.close()