软件质量测试第二周wordcount作业(代码片段)

安兹乌尔恭 安兹乌尔恭     2022-10-26     222

关键词:

一.github地址

https://github.com/WKX121/WC

二.PSP

PSP表格

PSP2.1

PSP阶段

预估耗时

(分钟)

实际耗时

(分钟)

Planning

计划

 25  25

· Estimate

· 估计这个任务需要多少时间

 25   25

Development

开发

300  340

· Analysis

· 需求分析 (包括学习新技术)

 40  40

· Design Spec

· 生成设计文档

 -  -

· Design Review

· 设计复审 (和同事审核设计文档)

 -  -

· Coding Standard

· 代码规范 (为目前的开发制定合适的规范)

 -  -

· Design

· 具体设计

 40  40

· Coding

· 具体编码

 180 200

· Code Review

· 代码复审

 40  60

· Test

· 测试(自我测试,修改代码,提交修改)

40  100

Reporting

报告

 120  180

· Test Report

· 测试报告

 60  60

· Size Measurement

· 计算工作量

 30  20

· Postmortem & Process Improvement Plan

· 事后总结, 并提出过程改进计划

 60  60
 

合计

 960  1150

三.思路

1.根据需求首先最传入main函数中的args解析出对应的命令,文件名

2.-c命令通过每次fgetc使wc_char加一

3.-w通过对空格和,的判断使wc_word加一

4.-l通过对/n判断使wc_line加一

 

四.程序的设计实现

通过对args不同数值的情况来处理各种统计模式,看对应哪个命令就调用相应的处理程序进行处理。然后将计数后的结果输出到指定txt文件当中。

五.代码说明

 

 

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main(int argc, char * argv[])

    int wc_char = 0;
    int wc_word = 1;
    int wc_line = 1;
    char filename[80];
    FILE *fp = NULL;
    if (argc == 3)
    
        fp = fopen(argv[2], "r");
        if (fp == NULL)
        
            printf("打开有误!\\n");
            printf("请按enter键继续....");
            _getch();
            exit(0);
            //...
        
            char ch;
            
           
            while (1)
            ch = fgetc(fp);
              wc_char++;
              if (ch == \' \'||ch==\',\')
            
                wc_word++;
            
            else if (ch == \'\\n\')
            
                wc_word++;
                wc_line++;
            
            else if (ch == EOF)
            
                break;
            
             
          
        if (strcmp(argv[1],"-c")==0)
        
            printf("The char count is %d\\n", wc_char);
            fp = fopen("result.txt","w");
            fprintf(fp,"字符数:%d\\n", wc_char); 
        
        else if (strcmp(argv[1],"-w")==0)
        
            printf("The word count is %d\\n", wc_word);
            fp = fopen("result.txt","w");
            fprintf(fp,"单词数:%d\\n", wc_word); 
        
        else if (strcmp(argv[1],"-l")==0)
        
            printf("The line count is %d\\n", wc_line);
            fp = fopen("result.txt","w");
            fprintf(fp,"行数:%d\\n", wc_line); 
        
        
        fclose(fp);
    
    if (argc == 4)
    
        fp = fopen(argv[3], "r");
        if (fp == NULL)
        
            printf("打开有误!\\n");
            printf("请按enter键继续....");
            _getch();
            exit(0);
            //...
        
            char ch;
            
           
            while (1)
            ch = fgetc(fp);
              wc_char++;
              if (ch == \' \'||ch==\',\')
            
                wc_word++;
            
            else if (ch == \'\\n\')
            
                wc_word++;
                wc_line++;
            
            else if (ch == EOF)
            
                break;
            
             
          
        if (strcmp(argv[1],"-c")==0&&strcmp(argv[2],"-w")==0)
        
            printf("The char count is %d\\n", wc_char);
            printf("The word count is %d\\n", wc_word);
            fp = fopen("result.txt","w");
            fprintf(fp,"字符数:%d\\n单词数:%d\\n", wc_char,wc_word); 
        
        if (strcmp(argv[1],"-c")==0&&strcmp(argv[2],"-l")==0)
        
            printf("The char count is %d\\n", wc_char);
            printf("The line count is %d\\n", wc_line);
            fp = fopen("result.txt","w");
            fprintf(fp,"字符数%d\\n行数:%d\\n", wc_char,wc_line); 
        
        if (strcmp(argv[1],"-w")==0&&strcmp(argv[2],"-l")==0)
        
            printf("The word count is %d\\n", wc_word);
            printf("The line count is %d\\n", wc_line);
            fp = fopen("result.txt","w");
            fprintf(fp,"单词数:%d\\n行数:%d\\n", wc_word,wc_line); 
        
        
        fclose(fp);
    
    if (argc == 5)
    
        fp = fopen(argv[4], "r");
        if (fp == NULL)
        
            printf("打开有误!\\n");
            printf("请按enter键继续....");
            _getch();
            exit(0);
            //...
        
            char ch;
            
           
            while (1)
            ch = fgetc(fp);
              wc_char++;
              if (ch == \' \'||ch==\',\')
            
                wc_word++;
            
            else if (ch == \'\\n\')
            
                wc_word++;
                wc_line++;
            
            else if (ch == EOF)
            
                break;
            
             
          
        if (strcmp(argv[1],"-c")==0)
        
            printf("The char count is %d\\n", wc_char);
            
        
        else if (strcmp(argv[1],"-w")==0)
        
            printf("The word count is %d\\n", wc_word);
           
        
        else if (strcmp(argv[1],"-l")==0)
        
            printf("The line count is %d\\n", wc_line);
            
        
        if (strcmp(argv[2],"-c")==0)
        
            printf("The char count is %d\\n", wc_char);
           
        
        else if (strcmp(argv[2],"-w")==0)
        
            printf("The word count is %d\\n", wc_word);
            
        
        else if (strcmp(argv[2],"-l")==0)
        
            printf("The line count is %d\\n", wc_line);
            
        
        if (strcmp(argv[3],"-c")==0)
        
            printf("The char count is %d\\n", wc_char);
           
        
        else if (strcmp(argv[3],"-w")==0)
        
            printf("The word count is %d\\n", wc_word);
            
        
        else if (strcmp(argv[3],"-l")==0)
        
            printf("The line count is %d\\n", wc_line);
           
        
         fp = fopen("result.txt","w");
            fprintf(fp,"字符数:%d\\n单词数:%d\\n行数:%d\\n", wc_char,wc_word,wc_line); 
        fclose(fp);
    

 

 

六.测试设计过程

10个测试:

1.-c

2.-w

3.-l

4.-c -w

5.-c -l

6.-w -l

7.-c -w -l

8.复杂符号测试

9.代码测试

10.复杂代码测试

七.参考文献

http://www.cnblogs.com/cool125/p/7560596.html

软件测试第二周作业wordcount(代码片段)

 软件测试第二周作业wordcountGithub地址https://github.com/mxz96102/word_countPSP2.1表格PSP2.1PSP 阶段预估耗时 (分钟)实际耗时 (分钟)Planning计划2530·Estimate·估计这个任务需要多少时间150252Development开发  ·Analysis· 查看详情

软件测试第二周作业wordcounter(代码片段)

Github项目地址WordCounteringithubPSP(PersonalSoftwareProcess)PSP2.1PSP阶段预估耗时实际耗时(分钟)实际耗时(分钟)Planning计划1017Estimate估计这个任务需要多少时间510Development开发545650-Analysis-需求分析(包括学习新技术)120160-DesignSpec-生... 查看详情

软件测试第二周个人作业wordcount程序实现(代码片段)

GitHub地址:https://github.com/Guchencc/WordCount一.PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划  ·Estimate·估计这个任务需要多少时间 300440Development开发  ·Analysis·需求分析(包括学习新技术) 20&n... 查看详情

软件测试第二周作业(代码片段)

一,github地址https://github.com/lc-xie/WordCount二,PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 25 25·Estimate·估计这个任务需要多少时间 25  25Development开发200 240·Analysis·需求分析(包括学习新... 查看详情

软件测试第二周个人作业--wordcount

1、Github项目地址:https://github.com/SSS-SY/wordcount 2、PSP2.1表格 PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 20 15·Estimate·估计这个任务需要多少时间 30 15Development开发 360 605·Analysi 查看详情

第二周作业wordcount(代码片段)

https://github.com/HuangDongPeng/WordCount.git1.1 PSPPSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 30 30·Estimate·估计这个任务需要多少时间 5h 12hDevelopment开发 2h 4h·Analysis·需求分析(包括学习新技 查看详情

第二周个人作业wordcount(代码片段)

一、GitHub地址https://github.com/JasonLiu1105/WordCount二、PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 20 20·Estimate·估计这个任务需要多少时间 2days 3daysDevelopment开发 1day 1day·Analysis·需求 查看详情

软件质量与测试第4周小组作业:wordcount优化(代码片段)

软件质量与测试第4周小组作业:WordCount优化一、GitHub地址https://github.com/fusidic/WC二、PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划3020·Estimate·估计这个任务需要多少时间3020Development开发470550·Analysis·需求分析(... 查看详情

第二周作业wordcount(代码片段)

github项目链接https://github.com/liqia/WordCount1.项目简介对程序设计语言源文件统计字符数、单词数、行数,统计结果以指定格式输出到默认文件中,以及其他扩展功能,并能够快速地处理多个文件。可执行程序命名为:wc.exe,该程序... 查看详情

软件质量与测试第4周小组作业:wordcount优化(代码片段)

GitHub项目地址https://github.com/Guchencc/WordCounter 组长:  陈佳文:负责词频统计模块与其他模块 组员:  屈佳烨:负责排序模块  苑子尚:负责输出模块  李一凡:负责输入模块  PSP表格 PSP2.1PSP阶段预估... 查看详情

wordcount第二周作业

GitHub地址GitHub地址为:https://github.com/Lovegoodstudy/WordCountPSP表格 PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划2020·Estimate·估计这个任务需要多少时间2020 Development开发1100 ·Analysis·需求分析(包括学习新技术)... 查看详情

软件质量与测试——wordcount编码实现及测试(代码片段)

1.GitHub地址   https://github.com/noblegongzi/WordCount2.PSP表格PSP2.1PSP 阶段预估耗时 (分钟)实际耗时 (分钟)Planning计划3050·Estimate·估计这个任务需要多少时间600840Development开发600840·Analysis·需求分析3040· 查看详情

《构建之法》-第二周

...成。 单元测试主要通过举了例子阐述了在多人合作的软件开发中,如何能让自己负责的模块功能定义尽量明确,模块内部的改变不会影响其他模块,而且模块的质量能得到稳定的、量化的保证。 一直以来交过很多代码作... 查看详情

软件测试第四周作业wordcount优化(代码片段)

Github地址https://github.com/husterC/WordCountGroupworkPSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划  ·Estimate·估计这个任务需要多少时间540 780Development开发  ·Analysis·需求分析(包括学习新技术) 60&... 查看详情

软件测试第4周小组作业:wordcount优化(代码片段)

小组github地址https://github.com/whoNamedCody/wcPro 基本任务一.PSP表格 PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 20 20·Estimate·估计这个任务需要多少时间 10 10Development开发 60 60·Analysis· 查看详情

软件工程网络15第二周作业-提出问题(代码片段)

提出问题快速通读教材《构建之法》,并参照提问模板,提出5个问题。如何提出有价值的问题?请看这个文章:http://www.cnblogs.com/rocedu/p/5167941.html,以及在互联网时代如何提问题。还有这些要点:-在每个问题后面,请说明哪一... 查看详情

20165306课下作业(第二周)

一、教材代码完成情况测试代码链接此代码作用是求和(1~5306)。二、带包的代码编译运行测试代码链接三、课后习题p161.Person.java2.两个,Person.class和Xiti.class代码链接 查看详情

《实时控制软件》第二周作业

首先制定各个变量名称入闸传感器:sensor_in;出闸传感器:sensor_out;起落杆上升:gan.raise();起落杆下降:gan.down();信号灯:light(1为绿,0为红);通行状态:A0为禁止通行,A1为允许通行;竖着写(在状态中判断事件)C代码片段cur_st... 查看详情