source: t/BarnOwl_Message_Zephyr.t @ 4733d68

Last change on this file since 4733d68 was cc27237, checked in by Jason Gross <jgross@mit.edu>, 9 years ago
Use g_utf8_casefold and g_utf8_normalize We define a convenience function compat_casefold in util.c for reuse in filters.
  • Property mode set to 100644
File size: 814 bytes
Line 
1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5use Test::More qw(no_plan);
6
7use BarnOwl;
8
9# Test that casefold_principal gets it right.
10#
11# NB(jgross): I got it wrong enough times writing it that I figured
12# putting in a test case for it was worth it.
13
14sub combine_user_realm {
15    my ($user, $realm) = @_;
16    return $user . '@' . $realm if defined $realm and $realm ne '';
17    return $user;
18}
19
20sub test_casefold_principal {
21    my ($user, $realm) = @_;
22    is(BarnOwl::Message::Zephyr::casefold_principal(combine_user_realm($user, $realm)),
23       combine_user_realm(lc($user), uc($realm)));
24}
25
26test_casefold_principal('');
27test_casefold_principal('FOO');
28test_casefold_principal('FOO', 'athena.mit.edu');
29test_casefold_principal('FOO@BAR', 'athena.mit.edu');
30test_casefold_principal('', 'athena.mit.edu');
31
321;
33
Note: See TracBrowser for help on using the repository browser.