var_id_test

PURPOSE ^

Test that the mex file eidors_var_id works

SYNOPSIS ^

function ok= var_id_test

DESCRIPTION ^

 Test that the mex file eidors_var_id works

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ok= var_id_test
0002 % Test that the mex file eidors_var_id works
0003 
0004 % (C) 2005 Andy Adler. License: GPL version 2 or version 3
0005 % $Id: var_id_test.m 1535 2008-07-26 15:36:27Z aadler $
0006 
0007 ok=1;
0008 
0009 %
0010 % Test 1:
0011 %  Test variable types
0012 %
0013 vv1.a=1; vv1.b='asfd'; vv1.c(1)=1; vv1.c(2)=2; vv1.s= @sin;
0014 vv2.a=1; vv2.b='asfd'; vv2.c(1)=1; vv2.c(2)=2; vv2.s= @sin;
0015 if ~strcmp( eidors_var_id(vv1), eidors_var_id(vv2) )
0016    warning('var_id_test: 1');
0017    ok=0;
0018 end
0019 
0020 vv2.a=1; vv2.b='asfd'; vv2.c(1)=1; vv2.c(2)=2; vv2.s= @sin;
0021 vv2.c(2)=3;
0022 if strcmp( eidors_var_id(vv1), eidors_var_id(vv2) )
0023    warning('var_id_test: 2'); ok=0;
0024 end
0025 
0026 vv2.a=1; vv2.b='asfd'; vv2.c(1)=1; vv2.c(2)=2; vv2.s= @sin;
0027 vv2.b='asdf';
0028 if strcmp( eidors_var_id(vv1), eidors_var_id(vv2) )
0029    warning('var_id_test: 3'); ok=0;
0030 end
0031 
0032 vv2.a=1; vv2.b='asfd'; vv2.c(1)=1; vv2.c(2)=2; vv2.s= @sin;
0033 vv2.s= @cos;
0034 if strcmp( eidors_var_id(vv1), eidors_var_id(vv2) )
0035    warning('var_id_test: 4'); ok=0;
0036 end
0037 
0038 vv2.a=1; vv2.b='asfd'; vv2.c(1)=1; vv2.c(2)=2; vv2.s= @sin;
0039 vv2.a=1 + eps;
0040 if strcmp( eidors_var_id(vv1), eidors_var_id(vv2) )
0041    warning('var_id_test: 5'); ok=0;
0042 end
0043 
0044 
0045 %
0046 % Test 2:
0047 %   test for random sorting
0048 %
0049 n_var= 10;
0050 for i=1:n_var
0051    str{i} = char( 'a' + floor(26*rand(1,20)) );
0052 end
0053 
0054 % Randomly order them, and assign to a variable
0055 var_id= '';
0056 for iter=1:2
0057    [jnk, idx] = sort( rand(1,n_var) );
0058    
0059    vv= struct([]);
0060    for i= 1:n_var; %idx
0061       eval(['vv(1).', str{i}, '=i;']);
0062    end
0063 
0064    evi= eidors_var_id( vv );
0065    if isempty(var_id)
0066       var_id= evi;
0067    elseif ~strcmp( var_id, evi );
0068       warning('var_id_test: 6'); ok=0;
0069    end
0070 end
0071 
0072 
0073 
0074 %
0075 % Test 7:
0076 %   test for random sorting
0077 %
0078 clear
0079 vv1.a=1; vv1.b='asfd'; vv1.c(1)=1; vv1.c(2)=2; vv1.s= @sin;
0080 vv3.aa=1; vv3.b='asfd'; vv3.c(1)=1; vv3.c(2)=2; vv3.s= @sin;
0081 if strcmp( eidors_var_id(vv1), eidors_var_id(vv3) )
0082    warning('var_id_test: 7 - expected'); ok=0;
0083 end

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005