|
rpm-build |
0f2925 |
(*
|
|
rpm-build |
0f2925 |
* ExtLib Testing Suite
|
|
rpm-build |
0f2925 |
* Copyright (C) 2004 Janne Hellsten
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0f2925 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0f2925 |
* version 2.1 of the License, or (at your option) any later version,
|
|
rpm-build |
0f2925 |
* with the special exception on linking described in file LICENSE.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0f2925 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0f2925 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0f2925 |
* Lesser General Public License for more details.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License along with this library; if not, write to the Free Software
|
|
rpm-build |
0f2925 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let in_range c a b =
|
|
rpm-build |
0f2925 |
let i = int_of_char c
|
|
rpm-build |
0f2925 |
and ai = int_of_char a
|
|
rpm-build |
0f2925 |
and bi = int_of_char b in
|
|
rpm-build |
0f2925 |
(i >= ai && i <= bi)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let check_chars s =
|
|
rpm-build |
0f2925 |
let len = String.length s in
|
|
rpm-build |
0f2925 |
if len > 0 then
|
|
rpm-build |
0f2925 |
begin
|
|
rpm-build |
0f2925 |
for i = 0 to len-1 do
|
|
rpm-build |
0f2925 |
let c = s.[i] in
|
|
rpm-build |
0f2925 |
if not (in_range c 'A' 'Z') then
|
|
rpm-build |
0f2925 |
if not (in_range c 'a' 'z') then
|
|
rpm-build |
0f2925 |
if not (in_range c '0' '9') then
|
|
rpm-build |
0f2925 |
assert (c = '/' || c = '+')
|
|
rpm-build |
0f2925 |
done
|
|
rpm-build |
0f2925 |
end
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let () =
|
|
rpm-build |
0f2925 |
Util.register1 "Base64" "random"
|
|
rpm-build |
0f2925 |
(fun () ->
|
|
rpm-build |
0f2925 |
for i = 0 to 64 do
|
|
rpm-build |
0f2925 |
let s = Util.random_string () in
|
|
rpm-build |
0f2925 |
let enc = Base64.encode_string s in
|
|
rpm-build |
0f2925 |
assert ((Base64.decode_string enc) = s);
|
|
rpm-build |
0f2925 |
check_chars enc
|
|
rpm-build |
0f2925 |
done)
|