/* Copyright (C) 2007 MySQL AB

   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 the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA */

#include <my_global.h>
#include <tap.h>
#include <m_string.h>

int
main(void)
{
  char foo[20];
    my_snprintf(foo, 10, ">%0f<", 0.987654321098765432);  
    ok(!strcmp(foo,">0.987654"), "foo value is %s, should be >0.987654", foo);
    my_snprintf(foo, 10, ">%.0f<", 0.987654321098765432);
    ok(!strcmp(foo,">1<"), "foo value is %s, should be >1<", foo);
    my_snprintf(foo, 10, ">%09.4f<", 0.987654321098765432);
    ok(!strcmp(foo,">0000.987"), "foo value is %s, should be >0000.987", foo);
    my_snprintf(foo, 10, ">%9.4f<", 0.987654321098765432);
    ok(!strcmp(foo,">   0.987"), "foo value is %s, should be >   0.987", foo);
    my_snprintf(foo, 10, ">%.1f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.9<"), "foo value is %s, should be >0.9<", foo);
    my_snprintf(foo, 5, ">%.1f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.9"), "foo value is %s, should be >0.9", foo);
    my_snprintf(foo, 4, ">%.1f<", 0.987654321098765432);
    ok(!strcmp(foo,">0."), "foo value is %s, should be >0.", foo);
    my_snprintf(foo, 10, ">%.3f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.987<"), "foo value is %s, should be >0.987<", foo);
    my_snprintf(foo, 10, ">%.4f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.9876<"), "foo value is %s, should be >0.9876<", foo);
    my_snprintf(foo, 10, ">%+.4f<", 0.987654321098765432);
    ok(!strcmp(foo,">+0.9876<"), "foo value is %s, should be >+0.9876<", foo);
    my_snprintf(foo, 10, ">%+.4f<", -0.987654321098765432); 
    ok(!strcmp(foo,">-0.9876<"), "foo value is %s, should be >-0.9876<", foo);
    my_snprintf(foo, 10, ">%+.5f<", 0.987654321098765432);
    ok(!strcmp(foo,">+0.98765"), "foo value is %s, should be >+0.98765", foo);
    my_snprintf(foo, 10, ">%.6f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.987654"), "foo value is %s, should be >0.987654", foo);
    my_snprintf(foo, 10, ">%.7f<", 0.987654321098765432);
    ok(!strcmp(foo,">0.987654"), "foo value is %s, should be >0.987654", foo);
    my_snprintf(foo, 10, ">%80f<", 0.987654321098765432);
    ok(!strcmp(foo,">        "), "foo value is %s, should be >        ", foo);
    my_snprintf(foo, 10, ">%.3f<", 10.65464);
    ok(!strcmp(foo,">10.654<"), "foo value is %s, should be >10.654", foo);
    return exit_status();
}


