From: <prn...@us...> - 2011-04-21 22:01:03
|
Revision: 8226 http://octave.svn.sourceforge.net/octave/?rev=8226&view=rev Author: prnienhuis Date: 2011-04-21 22:00:57 +0000 (Thu, 21 Apr 2011) Log Message: ----------- Tests added Modified Paths: -------------- trunk/octave-forge/main/io/inst/calccelladdress.m trunk/octave-forge/main/io/inst/parse_sp_range.m Modified: trunk/octave-forge/main/io/inst/calccelladdress.m =================================================================== --- trunk/octave-forge/main/io/inst/calccelladdress.m 2011-04-21 21:01:50 UTC (rev 8225) +++ trunk/octave-forge/main/io/inst/calccelladdress.m 2011-04-21 22:00:57 UTC (rev 8226) @@ -14,10 +14,11 @@ ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. -## Compute spreadsheet style cell address from 1-based row & column index. +## calccelladdress (R, C) - compute spreadsheet style cell address from +## row & column index (both 1-based). ## -## Max column index: 18278 (max ODS: 1024, OOXML: 16384). -## Max row index 1048576 (max ODS 1.2: 65536; OOXML / ODS 1.2-extended: 1048576). +## Max column index currently set to 18278 (max ODS: 1024, OOXML: 16384). +## Row limits for ODF and OOXML are 65536 and 1048576, resp. ## Author: Philip Nienhuis <prnienhuis at users.sf.net> ## Created: 2009-12-12 @@ -26,7 +27,6 @@ ## 2010-03-17 Simplified argument list, only row + column needed ## 2010-09-27 Made error message more comprehensible ## 2010-10-11 Added check for row range -## 2011-03-04 Textual fixes in header function [ celladdress ] = calccelladdress (row, column) @@ -48,4 +48,20 @@ endif celladdress = sprintf ("%s%d", str, row); -endfunction \ No newline at end of file +endfunction + +%!test +%! a = calccelladdress (1, 1); +%! assert (a, 'A1'); + +%!test +%! a = calccelladdress (378, 28); +%! assert (a, 'AB378'); + +%!test +%! a = calccelladdress (65536, 1024); +%! assert (a, 'AMJ65536'); + +%!test +%! a = calccelladdress (1048576, 16384); +%! assert (a, 'XFD1048576'); Modified: trunk/octave-forge/main/io/inst/parse_sp_range.m =================================================================== --- trunk/octave-forge/main/io/inst/parse_sp_range.m 2011-04-21 21:01:50 UTC (rev 8225) +++ trunk/octave-forge/main/io/inst/parse_sp_range.m 2011-04-21 22:00:57 UTC (rev 8226) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Philip Nienhuis <pr.nienhuis at users.sf.net> +## Copyright (C) 2009-2011 Philip Nienhuis <pr.nienhuis at users.sf.net> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -100,3 +100,20 @@ endif endfunction + +%!test +%! [a b c d e] = parse_sp_range ('A1:B2'); +%! assert ([a b c d e], ['A1', 2, 2, 1, 1]); + +%!test +%! [a b c d e] = parse_sp_range ('A1:AB200'); +%! assert ([a b c d e], ['A1', 200, 28, 1, 1]); + +%!test +%! [a b c d e] = parse_sp_range ('cd230:iY65536'); +%! assert ([a b c d e], ['CD230', 65307, 178, 230, 82]); + +%!test +%! [a b c d e] = parse_sp_range ('BvV12798 : xFd1054786'); +%! assert ([b c d e], [1041989, 14439, 12798, 1946]); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |