自动生成测试用文件

项目需要大量测试用文件,下面代码用Qt 编程自动生成50000个测试用txt文件。

没什么技术难度,仅作备份。

    static long i = 0;
    for( ; i<= 50000; i++)
    {
        QString fName = QString("File-%1.txt").arg(i,10,10,QLatin1Char('0'));
        QFile fileOut( fName );

        if (!fileOut.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text))
        {
            return false;
        }
        QTextStream streamFileOut(&fileOut);
        streamFileOut.setCodec("UTF-8");

        streamFileOut << QString( "    File Name : %1\r\n" ).arg(fName);
        streamFileOut << QString( "  Create Time : %1\r\n" ).arg(QDateTime::currentMSecsSinceEpoch());
        streamFileOut << QString( " ## This file is generated by NVR App automatically \n" );
        streamFileOut << QString( " ## Please don't modify manually \n" );

        for( int j=1;  j < 100 ; j++ )
        {
            streamFileOut <<  "\nUsage: unison [options]                                                           "
                              "\n            or unison root1 root2 [options]                                                   "
                              "\n            or unison profilename [options]                                                   "
                              "\n                                                                                              "
                              "\n        Basic options:                                                                        "
                              "\n         -auto              automatically accept default (nonconflicting) actions             "
                              "\n         -batch             batch mode: ask no questions at all                               "
                              "\n         -doc xxx           show documentation ('-doc topics' lists topics)                   "
                              "\n         -fat               use appropriate options for FAT filesystems                       "
                              "\n         -group             synchronize group attributes                                      "
                              "\n         -ignore xxx        add a pattern to the ignore list                                  "
                              "\n         -ignorenot xxx     add a pattern to the ignorenot list                               "
                              "\n         -nocreation xxx    prevent file creations on one replica                             "
                              "\n         -nodeletion xxx    prevent file deletions on one replica                             "
                              "\n         -noupdate xxx      prevent file updates and deletions on one replica                 "
                              "\n         -owner             synchronize owner                                                 "
                              "\n         -path xxx          path to synchronize                                               "
                              "\n         -perms n           part of the permissions which is synchronized                     "
                              "\n         -root xxx          root of a replica (should be used exactly twice)                  "
                              "\n         -silent            print nothing except error messages                               "
                              "\n         -terse             suppress status messages                                          "
                              "\n         -testserver        exit immediately after the connection to the server               "
                              "\n         -times             synchronize modification times                                    "
                              "\n         -version           print version and exit                                            "
                              "\n                                                                                              "
                              "\n        Advanced options:                                                                     "
                              "\n         -addprefsto xxx    file to add new prefs to                                          "
                              "\n         -addversionno      add version number to name of unison on server                    "
                              "\n         -backup xxx        add a pattern to the backup list                                  "
                              "\n         -backupcurr xxx    add a pattern to the backupcurr list                              "
                              "\n         -backupcurrnot xxx add a pattern to the backupcurrnot list                           "
                              "\n         -backupdir xxx     directory for storing centralized backups                         "
                              "\n         -backuploc xxx     where backups are stored ('local' or 'central')                   "
                              "\n         -backupnot xxx     add a pattern to the backupnot list                               "
                              "\n         -backupprefix xxx  prefix for the names of backup files                              "
                              "\n         -backups           keep backup copies of all files (see also 'backup')               "
                              "\n         -backupsuffix xxx  a suffix to be added to names of backup files                     "
                              "\n         -clientHostName xxx set host name of client                                          "
                              "\n         -confirmbigdel     ask about whole-replica (or path) deletes (default true)          "
                              "\n         -confirmmerge      ask for confirmation before committing results of a merge         "
                              "\n         -contactquietly    suppress the 'contacting server' message during startup           "
                              "\n         -copymax n         maximum number of simultaneous copyprog transfers                 "
                              "\n         -copyonconflict    keep copies of conflicting files                                  "
                              "\n         -copyprog xxx      external program for copying large files                          "
                              "\n         -copyprogrest xxx  variant of copyprog for resuming partial transfers                "
            streamFileOut << QString( "\r\nNumber   : %1, %2, %3, %4 \r\n" ).arg( j ).arg(j*j).arg(j*j*j).arg(j*j*j*j);
        }
        streamFileOut.flush();
        fileOut.close();
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值